Skip to content

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)) {
| ^

@Girgias Girgias requested a review from alexdowad February 7, 2023 12:19
@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