@@ -312,38 +312,41 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
312
312
long index ;
313
313
HashTable * ht = spl_array_get_hash_table (intern , 0 TSRMLS_CC );
314
314
315
- /* We cannot get the pointer pointer so we don't allow it here for now
316
- if (check_inherited && intern->fptr_offset_get) {
317
- return zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", NULL, offset);
318
- }*/
319
-
320
315
if (!offset ) {
321
316
return & EG (uninitialized_zval_ptr );
322
317
}
323
318
324
319
if ((type == BP_VAR_W || type == BP_VAR_RW ) && (ht -> nApplyCount > 0 )) {
325
320
zend_error (E_WARNING , "Modification of ArrayObject during sorting is prohibited" );
326
- return & EG (uninitialized_zval_ptr );;
321
+ return & EG (error_zval_ptr );;
327
322
}
328
323
329
324
switch (Z_TYPE_P (offset )) {
325
+ case IS_NULL :
326
+ Z_STRVAL_P (offset ) = "" ;
327
+ Z_STRLEN_P (offset ) = 0 ;
330
328
case IS_STRING :
331
329
if (zend_symtable_find (ht , Z_STRVAL_P (offset ), Z_STRLEN_P (offset )+ 1 , (void * * ) & retval ) == FAILURE ) {
332
- if (type == BP_VAR_W || type == BP_VAR_RW ) {
333
- zval * value ;
334
- ALLOC_INIT_ZVAL (value );
335
- zend_symtable_update (ht , Z_STRVAL_P (offset ), Z_STRLEN_P (offset )+ 1 , (void * * )& value , sizeof (void * ), NULL );
336
- zend_symtable_find (ht , Z_STRVAL_P (offset ), Z_STRLEN_P (offset )+ 1 , (void * * ) & retval );
337
- return retval ;
338
- } else {
339
- zend_error (E_NOTICE , "Undefined index: %s" , Z_STRVAL_P (offset ));
340
- return & EG (uninitialized_zval_ptr );
330
+ switch (type ) {
331
+ case BP_VAR_R :
332
+ zend_error (E_NOTICE , "Undefined index: %s" , Z_STRVAL_P (offset ));
333
+ case BP_VAR_UNSET :
334
+ case BP_VAR_IS :
335
+ retval = & EG (uninitialized_zval_ptr );
336
+ break ;
337
+ case BP_VAR_RW :
338
+ zend_error (E_NOTICE ,"Undefined index: %s" , Z_STRVAL_P (offset ));
339
+ case BP_VAR_W : {
340
+ zval * value ;
341
+ ALLOC_INIT_ZVAL (value );
342
+ zend_symtable_update (ht , Z_STRVAL_P (offset ), Z_STRLEN_P (offset )+ 1 , (void * * )& value , sizeof (void * ), (void * * )& retval );
343
+ }
341
344
}
342
- } else {
343
- return retval ;
344
345
}
345
- case IS_DOUBLE :
346
+ return retval ;
346
347
case IS_RESOURCE :
348
+ zend_error (E_STRICT , "Resource ID#%ld used as offset, casting to integer (%ld)" , Z_LVAL_P (offset ), Z_LVAL_P (offset ));
349
+ case IS_DOUBLE :
347
350
case IS_BOOL :
348
351
case IS_LONG :
349
352
if (offset -> type == IS_DOUBLE ) {
@@ -352,23 +355,27 @@ static zval **spl_array_get_dimension_ptr_ptr(int check_inherited, zval *object,
352
355
index = Z_LVAL_P (offset );
353
356
}
354
357
if (zend_hash_index_find (ht , index , (void * * ) & retval ) == FAILURE ) {
355
- if (type == BP_VAR_W || type == BP_VAR_RW ) {
356
- zval * value ;
357
- ALLOC_INIT_ZVAL (value );
358
- zend_hash_index_update (ht , index , (void * * )& value , sizeof (void * ), NULL );
359
- zend_hash_index_find (ht , index , (void * * ) & retval );
360
- return retval ;
361
- } else {
362
- zend_error (E_NOTICE , "Undefined offset: %ld" , index );
363
- return & EG (uninitialized_zval_ptr );
358
+ switch (type ) {
359
+ case BP_VAR_R :
360
+ zend_error (E_NOTICE , "Undefined offset: %ld" , index );
361
+ case BP_VAR_UNSET :
362
+ case BP_VAR_IS :
363
+ retval = & EG (uninitialized_zval_ptr );
364
+ break ;
365
+ case BP_VAR_RW :
366
+ zend_error (E_NOTICE , "Undefined offset: %ld" , index );
367
+ case BP_VAR_W : {
368
+ zval * value ;
369
+ ALLOC_INIT_ZVAL (value );
370
+ zend_hash_index_update (ht , index , (void * * )& value , sizeof (void * ), (void * * )& retval );
371
+ }
364
372
}
365
- } else {
366
- return retval ;
367
373
}
368
- break ;
374
+ return retval ;
369
375
default :
370
376
zend_error (E_WARNING , "Illegal offset type" );
371
- return & EG (uninitialized_zval_ptr );
377
+ return (type == BP_VAR_W || type == BP_VAR_RW ) ?
378
+ & EG (error_zval_ptr ) : & EG (uninitialized_zval_ptr );
372
379
}
373
380
} /* }}} */
374
381
@@ -664,7 +671,6 @@ SPL_METHOD(Array, offsetSet)
664
671
spl_array_write_dimension_ex (0 , getThis (), index , value TSRMLS_CC );
665
672
} /* }}} */
666
673
667
-
668
674
void spl_array_iterator_append (zval * object , zval * append_value TSRMLS_DC ) /* {{{ */
669
675
{
670
676
spl_array_object * intern = (spl_array_object * )zend_object_store_get_object (object TSRMLS_CC );
0 commit comments