File tree 3 files changed +29
-4
lines changed
3 files changed +29
-4
lines changed Original file line number Diff line number Diff line change @@ -39,6 +39,8 @@ PHP NEWS
39
39
. Fixed bug (segfault due to retval is not initialized). (Laruence)
40
40
41
41
- SPL:
42
+ . Fixed bug #62904 (Crash when cloning an object which inherits SplFixedArray)
43
+ (Laruence)
42
44
. Fixed bug #62616 (ArrayIterator::count() from IteratorIterator instance
43
45
gives Segmentation fault). (Laruence, Gustavo)
44
46
Original file line number Diff line number Diff line change @@ -223,10 +223,14 @@ static zend_object_value spl_fixedarray_object_new_ex(zend_class_entry *class_ty
223
223
if (orig && clone_orig ) {
224
224
spl_fixedarray_object * other = (spl_fixedarray_object * )zend_object_store_get_object (orig TSRMLS_CC );
225
225
intern -> ce_get_iterator = other -> ce_get_iterator ;
226
-
227
- intern -> array = emalloc (sizeof (spl_fixedarray ));
228
- spl_fixedarray_init (intern -> array , other -> array -> size TSRMLS_CC );
229
- spl_fixedarray_copy (intern -> array , other -> array TSRMLS_CC );
226
+ if (!other -> array ) {
227
+ /* leave a empty object, will be dtor later by CLONE handler */
228
+ zend_throw_exception (spl_ce_RuntimeException , "The instance wasn't initialized properly" , 0 TSRMLS_CC );
229
+ } else {
230
+ intern -> array = emalloc (sizeof (spl_fixedarray ));
231
+ spl_fixedarray_init (intern -> array , other -> array -> size TSRMLS_CC );
232
+ spl_fixedarray_copy (intern -> array , other -> array TSRMLS_CC );
233
+ }
230
234
}
231
235
232
236
while (parent ) {
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Bug #62904 (Crash when cloning an object which inherits SplFixedArray)
3
+ --FILE--
4
+ <?php
5
+
6
+ class foo extends SplFixedArray {
7
+ public function __construct ($ size ) {
8
+ }
9
+ }
10
+
11
+ $ x = new foo (2 );
12
+
13
+ try {
14
+ $ z = clone $ x ;
15
+ } catch (Exception $ e ) {
16
+ var_dump ($ e ->getMessage ());
17
+ }
18
+ --EXPECTF --
19
+ string (40 ) "The instance wasn't initialized properly "
You can’t perform that action at this time.
0 commit comments