Skip to content

Commit b870685

Browse files
committed
Fix leak on error in new serialization mechanism
1 parent a5e86d8 commit b870685

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--TEST--
2+
Failure while parsing data array for __unserialize()
3+
--FILE--
4+
<?php
5+
6+
class Test {
7+
public function __unserialize(array $data) { }
8+
}
9+
10+
var_dump(unserialize('O:4:"Test":1:{}'));
11+
12+
?>
13+
--EXPECTF--
14+
Notice: unserialize(): Unexpected end of serialized data in %s on line %d
15+
16+
Notice: unserialize(): Error at offset 14 of 15 bytes in %s on line %d
17+
bool(false)

ext/standard/var_unserializer.re

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -646,6 +646,7 @@ static inline int object_common(UNSERIALIZE_PARAMETER, zend_long elements, zend_
646646
if (!process_nested_data(UNSERIALIZE_PASSTHRU, Z_ARRVAL(ary), elements, NULL)) {
647647
ZVAL_DEREF(rval);
648648
GC_ADD_FLAGS(Z_OBJ_P(rval), IS_OBJ_DESTRUCTOR_CALLED);
649+
zval_ptr_dtor(&ary);
649650
return 0;
650651
}
651652

0 commit comments

Comments
 (0)