-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Fix bug 71572 #1761
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
Fix bug 71572 #1761
Conversation
@@ -1327,6 +1327,8 @@ static zend_never_inline void zend_binary_assign_op_obj_dim(zval *object, zval * | |||
static void zend_assign_to_string_offset(zval *str, zend_long offset, zval *value, zval *result) | |||
{ | |||
zend_string *old_str; | |||
char ch; | |||
zend_long string_len; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be size_t.
@nikic When using an invalid string offset, the assignment returns null. I did the same for assignment from an empty string. A quick look at zend_execute.c shows that some other failing assignments also return null. But, returning the unchanged character is an option too. As you know the core much better than me, just tell me which one you prefer. Edit: after thinking more about it, I now also think that returning the unchanged character is more consistent. Patch modified. |
@flaupretre As all the other dimension assignment failure cases return |
|
||
$str = "abc"; | ||
var_dump($str{0} = ""); | ||
var_dump($str); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a test case for $str{10} = ""
as well. Currently this will still extend the string, and likely additionally leave one uninitialized byte.
@nikic So, finally, as both are possible (and I don't have a strong opinion about it), which one is better, in your opinion ? |
Just thinking out loud. The options are:
I'd probably go for always returning null. |
edfd0e3
to
9c70ae2
Compare
New version. If RHS resolves to an empty string :
|
|
||
if (offset < 0) { | ||
if (offset < 0) { /* Error on negative offset */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this meant to be a new line? Using a tab here is strange.
This looks good to me, any objections to merging? |
Merged via be607e7. Per Andreas suggestion, I've moved the new comments to the next line. |
See https://bugs.php.net/bug.php?id=71572