com php-src: Do not edit the zval cause it might be in shared memory: ext/spl/spl_array.c

From: Date: Sun, 04 Oct 2015 02:50:38 +0000
Subject: com php-src: Do not edit the zval cause it might be in shared memory: ext/spl/spl_array.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89279@lists.php.net to get a copy of this message
Commit: 925412ee1c123c55e2b5badf6daf193e6c1bdd5b Author: Xinchen Hui <laruence@gmail.com> Sat, 3 Oct 2015 19:50:38 -0700 Parents: c147d90dbfcc4f9fd494215b7e5740e497d818c1 Branches: PHP-5.6 PHP-7.0 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=925412ee1c123c55e2b5badf6daf193e6c1bdd5b Log: Do not edit the zval cause it might be in shared memory Changed paths: M ext/spl/spl_array.c Diff: diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c index 2c65210..6ebbb7c 100644 --- a/ext/spl/spl_array.c +++ b/ext/spl/spl_array.c @@ -303,6 +303,8 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object, { spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC); zval **retval; + char *key; + uint len; long index; HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC); @@ -315,12 +317,12 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object, return &EG(error_zval_ptr);; } - switch(Z_TYPE_P(offset)) { - case IS_NULL: - Z_STRVAL_P(offset) = ""; - Z_STRLEN_P(offset) = 0; + switch (Z_TYPE_P(offset)) { case IS_STRING: - if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) { + key = Z_STRVAL_P(offset); + len = Z_STRLEN_P(offset) + 1; +string_offest: + if (zend_symtable_find(ht, key, len, (void **) &retval) == FAILURE) { switch (type) { case BP_VAR_R: zend_error(E_NOTICE, "Undefined index: %s", Z_STRVAL_P(offset)); @@ -333,11 +335,15 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object, case BP_VAR_W: { zval *value; ALLOC_INIT_ZVAL(value); - zend_symtable_update(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), (void **)&retval); + zend_symtable_update(ht, key, len, (void**)&value, sizeof(void*), (void **)&retval); } } } return retval; + case IS_NULL: + key = ""; + len = 1; + goto string_offest; case IS_RESOURCE: zend_error(E_STRICT, "Resource ID#%ld used as offset, casting to integer (%ld)", Z_LVAL_P(offset), Z_LVAL_P(offset)); case IS_DOUBLE:

« previous php.cvs (#89279) next »