Skip to content

Conversation

nielsdos
Copy link
Member

No description provided.

@nielsdos nielsdos merged commit 4495594 into php:master Jun 28, 2025
9 checks passed
zend_string *str_val, *tmp_str;

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