Skip to content

ext/intl: Use zval_get_tmp_string where possible #18966

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

Merged
merged 1 commit into from
Jun 28, 2025

Conversation

nielsdos
Copy link
Member

No description provided.

@nielsdos nielsdos merged commit 4495594 into php:master Jun 28, 2025
9 checks passed

str_val = zval_get_string(val);
str_val = zval_get_tmp_string(val, &tmp_str);
Copy link
Member

Choose a reason for hiding this comment

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

Isn't there an exception check missing here if we have a non stringable object (or an error handler promoting the array to string warning) in val?

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe, but does it matter? The exception will cause the VM to discard the result anyway. The only consequence is that we'll throw the exception a bit "late".

Copy link
Member

Choose a reason for hiding this comment

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

I guess, I'm just used with us dealing with those sorts of things more proactively now, and I guess this can matter if there is a follow-up object that does some stuff with side-effects in __toString() ?

Copy link
Member Author

Choose a reason for hiding this comment

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

If it's an internal object with a acst handler, it'll go through the cast handler, if that has side effects (which please god no) then it can cause problems.
If it's an internal or userland object, with a __toString method, then it won't call __toString if EG(exception) is already set. So in this case there can be no problems.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I forgot that the VM doesn't actual call follow-up methods in case of an Exception.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants