summaryrefslogtreecommitdiff
path: root/ext/spl/spl_array.c
diff options
context:
space:
mode:
authorULF WENDEL <uw@php.net>2012-10-22 13:37:37 +0200
committerULF WENDEL <uw@php.net>2012-10-22 13:37:37 +0200
commitdfeb91acc7d44cc5035db34a31310dc3075df11f (patch)
treee6e1b6c6898fc10eb602a9f5317371180d208b5b /ext/spl/spl_array.c
parent645f84e41bbda22c7a19326cd1a7df7994678976 (diff)
parentdbb72de6c75796803ed6ed103763a12eebc9e78e (diff)
downloadphp-git-dfeb91acc7d44cc5035db34a31310dc3075df11f.tar.gz
Merge branch 'PHP-5.3' of git.php.net:php-src into PHP-5.3
* 'PHP-5.3' of git.php.net:php-src: (123 commits) Re-fixed bug #60901 (Improve "tail" syntax for AIX installation) updated NEWS Fixed bug #63284 PCRE upgrade to 8.31 preg indenpent test script for #63055 Update libmagic.patch Add fix & missing fix Fixed bug #63307 (Unused variable in oci8.c) Fixed bug #63265 (Add ORA-00028 to the PHP_OCI_HANDLE_ERROR macro) - Updated to version 2012.7 (2012g) SUpport newer bisons. Merge the fix for #61964 to 5.3, which will fix #63304 indent better fix for #63055 Fixed bug #63055 (Segfault in zend_gc with SF2 testsuite) PHP 5.3.18 NEWS fix NEWS fix compilation failure on 32/64bit linux systems, when libmysql is used with ext/mysql Remove executable permission on inc Remove executable permission on phpt Fixed bug #63236 (Executable permission on various source files) ...
Diffstat (limited to 'ext/spl/spl_array.c')
-rw-r--r--[-rwxr-xr-x]ext/spl/spl_array.c70
1 files changed, 38 insertions, 32 deletions
diff --git a/ext/spl/spl_array.c b/ext/spl/spl_array.c
index 80ca5be612..11540decd9 100755..100644
--- a/ext/spl/spl_array.c
+++ b/ext/spl/spl_array.c
@@ -312,38 +312,41 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
long index;
HashTable *ht = spl_array_get_hash_table(intern, 0 TSRMLS_CC);
-/* We cannot get the pointer pointer so we don't allow it here for now
- if (check_inherited && intern->fptr_offset_get) {
- return zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", NULL, offset);
- }*/
-
if (!offset) {
return &EG(uninitialized_zval_ptr);
}
if ((type == BP_VAR_W || type == BP_VAR_RW) && (ht->nApplyCount > 0)) {
zend_error(E_WARNING, "Modification of ArrayObject during sorting is prohibited");
- return &EG(uninitialized_zval_ptr);;
+ return &EG(error_zval_ptr);;
}
switch(Z_TYPE_P(offset)) {
+ case IS_NULL:
+ Z_STRVAL_P(offset) = "";
+ Z_STRLEN_P(offset) = 0;
case IS_STRING:
if (zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval) == FAILURE) {
- if (type == BP_VAR_W || type == BP_VAR_RW) {
- zval *value;
- ALLOC_INIT_ZVAL(value);
- zend_symtable_update(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void**)&value, sizeof(void*), NULL);
- zend_symtable_find(ht, Z_STRVAL_P(offset), Z_STRLEN_P(offset)+1, (void **) &retval);
- return retval;
- } else {
- zend_error(E_NOTICE, "Undefined index: %s", Z_STRVAL_P(offset));
- return &EG(uninitialized_zval_ptr);
+ switch (type) {
+ case BP_VAR_R:
+ zend_error(E_NOTICE, "Undefined index: %s", Z_STRVAL_P(offset));
+ case BP_VAR_UNSET:
+ case BP_VAR_IS:
+ retval = &EG(uninitialized_zval_ptr);
+ break;
+ case BP_VAR_RW:
+ zend_error(E_NOTICE,"Undefined index: %s", Z_STRVAL_P(offset));
+ 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);
+ }
}
- } else {
- return retval;
}
- case IS_DOUBLE:
+ return retval;
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:
case IS_BOOL:
case IS_LONG:
if (offset->type == IS_DOUBLE) {
@@ -352,23 +355,27 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
index = Z_LVAL_P(offset);
}
if (zend_hash_index_find(ht, index, (void **) &retval) == FAILURE) {
- if (type == BP_VAR_W || type == BP_VAR_RW) {
- zval *value;
- ALLOC_INIT_ZVAL(value);
- zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), NULL);
- zend_hash_index_find(ht, index, (void **) &retval);
- return retval;
- } else {
- zend_error(E_NOTICE, "Undefined offset: %ld", index);
- return &EG(uninitialized_zval_ptr);
+ switch (type) {
+ case BP_VAR_R:
+ zend_error(E_NOTICE, "Undefined offset: %ld", index);
+ case BP_VAR_UNSET:
+ case BP_VAR_IS:
+ retval = &EG(uninitialized_zval_ptr);
+ break;
+ case BP_VAR_RW:
+ zend_error(E_NOTICE, "Undefined offset: %ld", index);
+ case BP_VAR_W: {
+ zval *value;
+ ALLOC_INIT_ZVAL(value);
+ zend_hash_index_update(ht, index, (void**)&value, sizeof(void*), (void **)&retval);
+ }
}
- } else {
- return retval;
}
- break;
+ return retval;
default:
zend_error(E_WARNING, "Illegal offset type");
- return &EG(uninitialized_zval_ptr);
+ return (type == BP_VAR_W || type == BP_VAR_RW) ?
+ &EG(error_zval_ptr) : &EG(uninitialized_zval_ptr);
}
} /* }}} */
@@ -664,7 +671,6 @@ SPL_METHOD(Array, offsetSet)
spl_array_write_dimension_ex(0, getThis(), index, value TSRMLS_CC);
} /* }}} */
-
void spl_array_iterator_append(zval *object, zval *append_value TSRMLS_DC) /* {{{ */
{
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);