summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2015-10-03 19:50:38 -0700
committerXinchen Hui <laruence@gmail.com>2015-10-03 19:50:38 -0700
commit925412ee1c123c55e2b5badf6daf193e6c1bdd5b (patch)
treebe876f36532aba82673753905dd729fb9c3fec70
parentc147d90dbfcc4f9fd494215b7e5740e497d818c1 (diff)
downloadphp-git-925412ee1c123c55e2b5badf6daf193e6c1bdd5b.tar.gz
Do not edit the zval cause it might be in shared memory
-rw-r--r--ext/spl/spl_array.c18
1 files changed, 12 insertions, 6 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 2c65210b98..6ebbb7c068 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: