@@ -311,13 +311,13 @@ static zend_object *spl_fixedarray_object_clone(zend_object *old_object)
311
311
312
312
static zend_long spl_offset_convert_to_long (zval * offset ) /* {{{ */
313
313
{
314
- zend_ulong idx ;
314
+ zend_long index ;
315
315
316
316
try_again :
317
317
switch (Z_TYPE_P (offset )) {
318
318
case IS_STRING :
319
- if (ZEND_HANDLE_NUMERIC (Z_STR_P (offset ), idx )) {
320
- return idx ;
319
+ if (IS_LONG == is_numeric_str_function (Z_STR_P (offset ), & index , NULL )) {
320
+ return index ;
321
321
}
322
322
break ;
323
323
case IS_DOUBLE :
@@ -332,9 +332,13 @@ static zend_long spl_offset_convert_to_long(zval *offset) /* {{{ */
332
332
offset = Z_REFVAL_P (offset );
333
333
goto try_again ;
334
334
case IS_RESOURCE :
335
+ zend_error (E_WARNING , "Resource ID#%d used as offset, casting to integer (%d)" ,
336
+ Z_RES_HANDLE_P (offset ), Z_RES_HANDLE_P (offset ));
335
337
return Z_RES_HANDLE_P (offset );
336
- }
337
- return -1 ;
338
+ }
339
+
340
+ zend_type_error ("Illegal offset type" );
341
+ return 0 ;
338
342
}
339
343
340
344
static zval * spl_fixedarray_object_read_dimension_helper (spl_fixedarray_object * intern , zval * offset )
@@ -348,13 +352,13 @@ static zval *spl_fixedarray_object_read_dimension_helper(spl_fixedarray_object *
348
352
return NULL ;
349
353
}
350
354
351
- if (Z_TYPE_P (offset ) != IS_LONG ) {
352
- index = spl_offset_convert_to_long (offset );
353
- } else {
354
- index = Z_LVAL_P (offset );
355
+ index = spl_offset_convert_to_long (offset );
356
+ if (EG (exception )) {
357
+ return NULL ;
355
358
}
356
359
357
360
if (index < 0 || index >= intern -> array .size ) {
361
+ // TODO Change error message and use OutOfBound SPL Exception?
358
362
zend_throw_exception (spl_ce_RuntimeException , "Index invalid or out of range" , 0 );
359
363
return NULL ;
360
364
} else {
@@ -400,13 +404,13 @@ static void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *
400
404
return ;
401
405
}
402
406
403
- if (Z_TYPE_P (offset ) != IS_LONG ) {
404
- index = spl_offset_convert_to_long (offset );
405
- } else {
406
- index = Z_LVAL_P (offset );
407
+ index = spl_offset_convert_to_long (offset );
408
+ if (EG (exception )) {
409
+ return ;
407
410
}
408
411
409
412
if (index < 0 || index >= intern -> array .size ) {
413
+ // TODO Change error message and use OutOfBound SPL Exception?
410
414
zend_throw_exception (spl_ce_RuntimeException , "Index invalid or out of range" , 0 );
411
415
return ;
412
416
} else {
@@ -438,13 +442,13 @@ static void spl_fixedarray_object_unset_dimension_helper(spl_fixedarray_object *
438
442
{
439
443
zend_long index ;
440
444
441
- if (Z_TYPE_P (offset ) != IS_LONG ) {
442
- index = spl_offset_convert_to_long (offset );
443
- } else {
444
- index = Z_LVAL_P (offset );
445
+ index = spl_offset_convert_to_long (offset );
446
+ if (EG (exception )) {
447
+ return ;
445
448
}
446
449
447
450
if (index < 0 || index >= intern -> array .size ) {
451
+ // TODO Change error message and use OutOfBound SPL Exception?
448
452
zend_throw_exception (spl_ce_RuntimeException , "Index invalid or out of range" , 0 );
449
453
return ;
450
454
} else {
@@ -472,10 +476,9 @@ static int spl_fixedarray_object_has_dimension_helper(spl_fixedarray_object *int
472
476
zend_long index ;
473
477
int retval ;
474
478
475
- if (Z_TYPE_P (offset ) != IS_LONG ) {
476
- index = spl_offset_convert_to_long (offset );
477
- } else {
478
- index = Z_LVAL_P (offset );
479
+ index = spl_offset_convert_to_long (offset );
480
+ if (EG (exception )) {
481
+ return 0 ;
479
482
}
480
483
481
484
if (index < 0 || index >= intern -> array .size ) {
0 commit comments