Skip to content

Conversation

@NWilson
Copy link
Member

@NWilson NWilson commented Mar 19, 2025

The value "" is a char[1] array with a single zero byte. It should not be cast to a PCRE2_SPTR, which is a pointer to an array of 1/2/4-byte values. It may not even have the required pointer alignment for a PCRE2_SPTR (in 16 or 32 bit mode).

The pointer is never dereferenced anyway, since the length is zero.

Reported by Microsoft's OACR linter.

As a quick and easy fix, I'll just set it a non-null value with the shortest possible length (no zero-length arrays allowed in C).

This has the best chance of silencing linters that want us to have a non-NULL value for the zero-length pointer.

@NWilson NWilson merged commit d606adf into master Mar 24, 2025
35 checks passed
@NWilson NWilson deleted the user/niwilson/bad-casts branch March 24, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants