1
0
mirror of https://github.com/php/php-src.git synced 2026-04-25 00:48:25 +02:00

restore the old behavior for the assignment to string offset

This commit is contained in:
Anatol Belski
2014-08-29 17:28:53 +02:00
parent a9c5dab1d0
commit d3fb1859f0
+4 -4
View File
@@ -762,11 +762,11 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu
/* XXX String offset is uint32_t in _zval_struct, so can address only 2^32+1 space.
To make the offset get over that barier, we need to make str_offset size_t and that
would grow zval size by 8 bytes (currently from 16 to 24) on 64 bit build. */
size_t offset = (size_t)Z_STR_OFFSET_IDX_P(str_offset);
uint32_t offset = Z_STR_OFFSET_IDX_P(str_offset);
zend_string *old_str;
if ((zend_long)offset < 0) {
zend_error(E_WARNING, "Illegal string offset: %zd", offset);
if ((int)offset < 0) {
zend_error(E_WARNING, "Illegal string offset: %d", offset);
zend_string_release(Z_STR_P(str));
if (result) {
ZVAL_NULL(result);
@@ -776,7 +776,7 @@ static void zend_assign_to_string_offset(zval *str_offset, zval *value, int valu
old_str = Z_STR_P(str);
if (offset >= Z_STRLEN_P(str)) {
size_t old_len = Z_STRLEN_P(str);
int old_len = Z_STRLEN_P(str);
Z_STR_P(str) = zend_string_realloc(Z_STR_P(str), offset + 1, 0);
Z_TYPE_INFO_P(str) = IS_STRING_EX;
memset(Z_STRVAL_P(str) + old_len, ' ', offset - old_len);