Skip to content

Fix #81429: SplFixedArray::setSize(0) called during offsetSet() #7486

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions ext/spl/spl_fixedarray.c
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,11 @@ static void spl_fixedarray_object_write_dimension_helper(spl_fixedarray_object *
return;
} else {
zval_ptr_dtor(&(intern->array.elements[index]));
// Elements may be released by the destructor
if (!intern->array.elements) {
Copy link
Contributor

@TysonAndre TysonAndre Sep 11, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This won't solve the general case. The array can be reallocated to a different pointer whether it's shrinking or expanding the size (e.g. if realloc can't extend the array)

<?php
class HasDestructor {
    public function __destruct() {
        $GLOBALS['values']->setSize(1);
    }
}
$values = new SplFixedArray(1000);
$values[999] = new HasDestructor();
$values->setSize(1);

USE_ZEND_ALLOC=0 valgrind sapi/cli/php test.php

==3393== Memcheck, a memory error detector
==3393== Copyright (C) 2002-2017, and GNU GPL'd, by Julian Seward et al.
==3393== Using Valgrind-3.15.0 and LibVEX; rerun with -h for copyright info
==3393== Command: sapi/cli/php test.php
==3393==
==3393== Invalid read of size 4
==3393==    at 0x7BA60D: zend_gc_delref (zend_types.h:1183)
==3393==    by 0x7BAC3D: zend_objects_store_del (zend_objects_API.c:185)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==  Address 0x5258090 is 0 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
==3393== Invalid read of size 4
==3393==    at 0x7BA636: zend_gc_delref (zend_types.h:1185)
==3393==    by 0x7BAC3D: zend_objects_store_del (zend_objects_API.c:185)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==  Address 0x5258090 is 0 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
==3393== Invalid write of size 4
==3393==    at 0x7BA63F: zend_gc_delref (zend_types.h:1185)
==3393==    by 0x7BAC3D: zend_objects_store_del (zend_objects_API.c:185)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==  Address 0x5258090 is 0 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
==3393== Invalid read of size 4
==3393==    at 0x7BA645: zend_gc_delref (zend_types.h:1185)
==3393==    by 0x7BAC3D: zend_objects_store_del (zend_objects_API.c:185)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==  Address 0x5258090 is 0 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
==3393== Invalid read of size 4
==3393==    at 0x7BA5BE: zend_gc_refcount (zend_types.h:1155)
==3393==    by 0x7BAC4E: zend_objects_store_del (zend_objects_API.c:190)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==  Address 0x5258090 is 0 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
==3393== Invalid read of size 4
==3393==    at 0x7BAC5B: zend_objects_store_del (zend_objects_API.c:191)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==    by 0x77F3F6: execute_ex (zend_vm_execute.h:54620)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==  Address 0x5258098 is 8 bytes inside a block of size 40 free'd
==3393==    at 0x483CA3F: free (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x692357: _efree_custom (zend_alloc.c:2428)
==3393==    by 0x6924AE: _efree (zend_alloc.c:2548)
==3393==    by 0x7BAD9C: zend_objects_store_del (zend_objects_API.c:204)
==3393==    by 0x7B2FC1: zend_object_release (zend_objects_API.h:75)
==3393==    by 0x7B375D: zend_objects_destroy_object (zend_objects.c:180)
==3393==    by 0x7BAC31: zend_objects_store_del (zend_objects_API.c:184)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==  Block was alloc'd at
==3393==    at 0x483B7F3: malloc (in /usr/lib/x86_64-linux-gnu/valgrind/vgpreload_memcheck-amd64-linux.so)
==3393==    by 0x693676: __zend_malloc (zend_alloc.c:3043)
==3393==    by 0x6922E6: _malloc_custom (zend_alloc.c:2419)
==3393==    by 0x692430: _emalloc (zend_alloc.c:2538)
==3393==    by 0x7B379E: zend_objects_new (zend_objects.c:186)
==3393==    by 0x6D819D: _object_and_properties_init (zend_API.c:1642)
==3393==    by 0x6D8282: object_init_ex (zend_API.c:1665)
==3393==    by 0x7211C3: ZEND_NEW_SPEC_CONST_UNUSED_HANDLER (zend_vm_execute.h:10148)
==3393==    by 0x7807B1: execute_ex (zend_vm_execute.h:55495)
==3393==    by 0x784B96: zend_execute (zend_vm_execute.h:58951)
==3393==    by 0x6D0C66: zend_execute_scripts (zend.c:1761)
==3393==    by 0x62E486: php_execute_script (main.c:2519)
==3393==
php: /path/to/php-src/Zend/zend_objects_API.c:195: zend_objects_store_del: Assertion `(!(((zend_uintptr_t)((executor_globals.objects_store).object_buckets[handle])) & (1<<0)))' failed.
==3393==
==3393== Process terminating with default action of signal 6 (SIGABRT)
==3393==    at 0x4AC718B: raise (raise.c:51)
==3393==    by 0x4AA6858: abort (abort.c:79)
==3393==    by 0x4AA6728: __assert_fail_base.cold (assert.c:92)
==3393==    by 0x4AB7F35: __assert_fail (assert.c:101)
==3393==    by 0x7BACC6: zend_objects_store_del (zend_objects_API.c:195)
==3393==    by 0x6CC5AF: rc_dtor_func (zend_variables.c:57)
==3393==    by 0x6CC52E: i_zval_ptr_dtor (zend_variables.h:44)
==3393==    by 0x6CC752: zval_ptr_dtor (zend_variables.c:84)
==3393==    by 0x50765C: spl_fixedarray_dtor_range (spl_fixedarray.c:151)
==3393==    by 0x5077C2: spl_fixedarray_resize (spl_fixedarray.c:188)
==3393==    by 0x509219: zim_SplFixedArray_setSize (spl_fixedarray.c:681)
==3393==    by 0x70D80D: ZEND_DO_FCALL_SPEC_RETVAL_UNUSED_HANDLER (zend_vm_execute.h:1761)
==3393==
==3393== HEAP SUMMARY:
==3393==     in use at exit: 1,763,642 bytes in 10,331 blocks
==3393==   total heap usage: 11,050 allocs, 719 frees, 2,092,132 bytes allocated
==3393==
==3393== LEAK SUMMARY:
==3393==    definitely lost: 20,288 bytes in 634 blocks
==3393==    indirectly lost: 40 bytes in 1 blocks
==3393==      possibly lost: 1,113,002 bytes in 8,484 blocks
==3393==    still reachable: 630,312 bytes in 1,212 blocks
==3393==         suppressed: 0 bytes in 0 blocks
==3393== Rerun with --leak-check=full to see details of leaked memory
==3393==
==3393== For lists of detected and suppressed errors, rerun with: -s
==3393== ERROR SUMMARY: 6 errors from 6 contexts (suppressed: 0 from 0)

zend_throw_exception(spl_ce_RuntimeException, "Index invalid or out of range", 0);
return;
}
ZVAL_COPY_DEREF(&intern->array.elements[index], value);
}
}
Expand Down
20 changes: 20 additions & 0 deletions ext/spl/tests/bug81429.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
--TEST--
Bug #81429 SplFixedArray::setSize(0) called during offsetSet()
--FILE--
<?php
class HasDestructor {
public function __destruct() {
$GLOBALS['values']->setSize(0);
}
}

$values = new SplFixedArray(1);
$values->offsetSet(0, new HasDestructor());
$values->offsetSet(0, null);
?>
--EXPECTF--
Fatal error: Uncaught RuntimeException: Index invalid or out of range in %s.php:%d
Stack trace:
#0 %s.php(%d): SplFixedArray->offsetSet(0, NULL)
#1 {main}
thrown in %s.php on line %d