Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ext/mbstring: fix new_value length check #10532

Closed
wants to merge 1 commit into from

Conversation

MaxKellermann
Copy link
Contributor

Commit 8bbd095 added a check rejecting empty strings; in the merge commiot 379d9a1 however it was changed to a NULL check, one that did not make sense because ZSTR_VAL() is guaranteed to never be NULL; the length check was accidently removed by that merge commit.

This bug was found by GCC's -Waddress warning:

ext/mbstring/mbstring.c:748:27: warning: the comparison will always evaluate as ‘true’ for the address of ‘val’ will never be NULL [-Waddress]
748 | if (!new_value || !ZSTR_VAL(new_value)) {
| ^

@alexdowad
Copy link
Contributor

Thanks!

I seem to remember @cmb69 once commented on that piece of code, saying that the check didn't make sense... thanks for figuring out why it was that way.

Commit 8bbd095 added a check rejecting empty strings; in the
merge commiot 379d9a1 however it was changed to a NULL check,
one that did not make sense because ZSTR_VAL() is guaranteed to never
be NULL; the length check was accidently removed by that merge commit.

This bug was found by GCC's -Waddress warning:

 ext/mbstring/mbstring.c:748:27: warning: the comparison will always evaluate as ‘true’ for the address of ‘val’ will never be NULL [-Waddress]
   748 |         if (!new_value || !ZSTR_VAL(new_value)) {
       |                           ^
@Girgias Girgias closed this in 243865a Feb 20, 2023
@MaxKellermann MaxKellermann deleted the mbstring_empty_check branch March 7, 2023 12:02
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