On Fri, Feb 12, 2016 at 12:44 AM, François Laupretre <franc...@php.net>
wrote:

> Le 11/02/2016 17:25, Andrea Faulds a écrit :
>
>> Hi François,
>>
>> François Laupretre wrote:
>>
>>> String offsets are full of oddities :
>>>
>>> $str = "abc";
>>> $str{0} = '';
>>> var_dump($str); // -> string(3) "bc" (read as "\0bc")
>>>
>>> Assigning an empty string to a string offset inserts a null byte because
>>> the string length is not checked in zend_assign_to_string_offset().
>>>
>>> I see this as a bug. IMO, this case should raise a warning and the
>>> string should remain unchanged.
>>>
>>> Thoughts before I register a bug and a PR ?
>>>
>>
>> Wow, that's quite egregious. I think this should be considered a bug and
>> fixed as soon as possible. Whether it should go into 7.0.x or 7.1 is
>> possibly a matter for debate, though.
>>
>> Thanks
>>
>>
> OK. Bug registered (https://bugs.php.net/bug.php?id=71572) along with PR (
> https://github.com/php/php-src/pull/1761).
>
> Can someone please review/merge the PR and close the bug ?
>

This fix has been merged into master (targeting 7.1), thanks!

Another issue mentioned in this thread is the spurious array conversion
that happens for empty strings. We have an existing bug report for this:
https://bugs.php.net/bug.php?id=53432 I've created a PR to fix this issue:
https://github.com/php/php-src/pull/1764 If there are no objections, I'll
merge this for 7.1 as well.

Nikita

Reply via email to