Skip to content

Fix substr_replace with slots in repl_ht being UNDEF #10323

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

Closed
wants to merge 1 commit into from

Conversation

nielsdos
Copy link
Member

@nielsdos nielsdos commented Jan 14, 2023

The check that was supposed to check whether the array slot was UNDEF was wrong and never triggered. This resulted in a replacement with the empty string or the wrong string instead of the correct one. The correct check pattern can be observed higher up in the function's code.

EDIT: Appveyor failure due to Bug #48182: ssl handshake fails during asynchronous socket connection [C:\projects\php-src\ext\openssl\tests\bug48182.phpt], which is unrelated

Copy link
Member

@iluuu1994 iluuu1994 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you! On PHP-8.2 there are two such cases.

if (repl_ht != IS_UNDEF) {

if (repl_ht != IS_UNDEF) {

However merges this should adjust for both, or it can be done in a follow-up.

@iluuu1994
Copy link
Member

iluuu1994 commented Jan 14, 2023

Oh, nevermind. It's correct there 😄 Nope, just linked the wrong line 🙂

@nielsdos
Copy link
Member Author

I can do a follow-up if you want. The only "issue" then I guess is that the PHP-8.1 branch will not be a subset of PHP-8.2+ ?

@iluuu1994
Copy link
Member

@nielsdos We must merge upstream, so whoever merges this will need to resolve the merge conflict, and thus just adjusting the other line should be ok. Would be nice if we had a test for the unpacked case too, we could probably create an unpacked array like this:

$array = ['foo', 42 => 'bar', 'baz'];
unset($array[42]);

But I haven't tested it.

@nielsdos
Copy link
Member Author

@nielsdos We must merge upstream, so whoever merges this will need to resolve the merge conflict, and thus just adjusting the other line should be ok.

Whoops... of course, that makes sense 😅

Would be nice if we had a test for the unpacked case too, we could probably create an unpacked array like this:

$array = ['foo', 42 => 'bar', 'baz'];
unset($array[42]);

But I haven't tested it.

I'll check tomorrow if this test would work with some good old printf debugging, and add it if that is the case :)

The check that was supposed to check whether the array slot was UNDEF
was wrong and never triggered. This resulted in a replacement with the
empty string or the wrong string instead of the correct one. The correct
check pattern can be observed higher up in the function's code.
@nielsdos nielsdos force-pushed the fix-string-substr-replace branch from 6c72034 to a5de492 Compare January 15, 2023 13:03
@nielsdos
Copy link
Member Author

Yep your test works, thanks. I updated the test file to include your test.

@iluuu1994
Copy link
Member

@nielsdos Perfect, thank you!

@Girgias Girgias self-assigned this Jan 15, 2023
@Girgias Girgias closed this in 4bbbe6d Jan 15, 2023
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.

3 participants