Browse Source

Fixed bug #42817 (clone() on a non-object does not result in a fatal error)

PECL
Ilia Alshanetsky 19 years ago
parent
commit
4c619a3f5f
  1. 4
      Zend/tests/bug36071.phpt
  2. 9
      Zend/tests/bug42817.phpt
  3. 2
      Zend/tests/bug42818.phpt
  4. 4
      Zend/zend_vm_def.h

4
Zend/tests/bug36071.phpt

@ -6,8 +6,6 @@ error_reporting=4095
<?php
$a = clone 0;
$a[0]->b = 0;
echo "ok\n";
?>
--EXPECTF--
Warning: __clone method called on non-object in %sbug36071.php on line 2
ok
Fatal error: __clone method called on non-object in %sbug36071.php on line 2

9
Zend/tests/bug42817.phpt

@ -0,0 +1,9 @@
--TEST--
Bug #42817 (clone() on a non-object does not result in a fatal error)
--FILE--
<?php
$a = clone(null);
array_push($a->b, $c);
?>
--EXPECTF--
Fatal error: __clone method called on non-object in %sbug42817.php on line 2

2
Zend/tests/bug42818.phpt

@ -5,5 +5,5 @@ Bug #42818 ($foo = clone(array()); leaks memory)
$foo = clone(array());
?>
--EXPECTF--
Warning: __clone method called on non-object in %sbug42818.php on line 2
Fatal error: __clone method called on non-object in %sbug42818.php on line 2

4
Zend/zend_vm_def.h

@ -2579,10 +2579,10 @@ ZEND_VM_HANDLER(110, ZEND_CLONE, CONST|TMP|VAR|UNUSED|CV, ANY)
zend_object_clone_obj_t clone_call;
if (!obj || Z_TYPE_P(obj) != IS_OBJECT) {
zend_error(E_WARNING, "__clone method called on non-object");
zend_error_noreturn(E_ERROR, "__clone method called on non-object");
EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr);
EX_T(opline->result.u.var).var.ptr->refcount++;
FREE_OP1();
FREE_OP1_IF_VAR();
ZEND_VM_NEXT_OPCODE();
}

Loading…
Cancel
Save