Skip to content

Commit 321f4f1

Browse files
committed
Fixed bug #64106: Segfault on SplFixedArray[][x] = y when extended
1 parent ec53b60 commit 321f4f1

File tree

4 files changed

+28
-2
lines changed

4 files changed

+28
-2
lines changed

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ PHP NEWS
1717
- FPM:
1818
. Fixed bug #63999 (php with fpm fails to build on Solaris 10 or 11). (Adam)
1919

20+
- SPL:
21+
. Fixed bug #64106 (Segfault on SplFixedArray[][x] = y when extended). (Nikita Popov)
22+
2023
17 Jan 2013, PHP 5.3.21
2124

2225
- Zend Engine:

ext/spl/spl_array.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,7 +387,11 @@ static zval *spl_array_read_dimension_ex(int check_inherited, zval *object, zval
387387
spl_array_object *intern = (spl_array_object*)zend_object_store_get_object(object TSRMLS_CC);
388388
if (intern->fptr_offset_get) {
389389
zval *rv;
390-
SEPARATE_ARG_IF_REF(offset);
390+
if (!offset) {
391+
ALLOC_INIT_ZVAL(offset);
392+
} else {
393+
SEPARATE_ARG_IF_REF(offset);
394+
}
391395
zend_call_method_with_1_params(&object, Z_OBJCE_P(object), &intern->fptr_offset_get, "offsetGet", &rv, offset);
392396
zval_ptr_dtor(&offset);
393397
if (rv) {

ext/spl/spl_fixedarray.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -361,7 +361,11 @@ static zval *spl_fixedarray_object_read_dimension(zval *object, zval *offset, in
361361

362362
if (intern->fptr_offset_get) {
363363
zval *rv;
364-
SEPARATE_ARG_IF_REF(offset);
364+
if (!offset) {
365+
ALLOC_INIT_ZVAL(offset);
366+
} else {
367+
SEPARATE_ARG_IF_REF(offset);
368+
}
365369
zend_call_method_with_1_params(&object, intern->std.ce, &intern->fptr_offset_get, "offsetGet", &rv, offset);
366370
zval_ptr_dtor(&offset);
367371
if (rv) {

ext/spl/tests/bug64106.phpt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--TEST--
2+
Bug #64106: Segfault on SplFixedArray[][x] = y when extended
3+
--FILE--
4+
<?php
5+
6+
class MyFixedArray extends SplFixedArray {
7+
public function offsetGet($offset) {}
8+
}
9+
10+
$array = new MyFixedArray(10);
11+
$array[][1] = 10;
12+
13+
?>
14+
--EXPECTF--
15+
Notice: Indirect modification of overloaded element of MyFixedArray has no effect in %s on line %d

0 commit comments

Comments
 (0)