Re: [RFC] Generalize support of negative string offsets
| From: | Andrea Faulds | Date: | Thu, 11 Feb 2016 16:25:38 +0000 |
| Subject: | Re: [RFC] Generalize support of negative string offsets | ||
| References: | 1 2 | Groups: | php.internals |
| Request: | Send a blank email to internals+get-91209@lists.php.net to get a copy of this message | ||
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 -- Andrea Faulds https://ajf.me/