fix crash caused by uninitialized zval when unserializing properties
authorMichael Wallner <mike@php.net>
Thu, 19 May 2022 08:21:09 +0000 (10:21 +0200)
committerMichael Wallner <mike@php.net>
Thu, 19 May 2022 08:25:49 +0000 (10:25 +0200)
ion_private.h
tests/unserialize/executor_globals.phpt [new file with mode: 0644]

index 21e355879bfaf57d65a099b3b77d5b453a5c9140..27c26705c82003595bd00058c5722a7a7393abb5 100644 (file)
@@ -2360,6 +2360,7 @@ static void php_ion_unserialize_props(php_ion_unserializer *ser, zval *return_va
                ION_CATCH();
 
                zval zvalue;
+               ZVAL_UNDEF(&zvalue);
                php_ion_unserialize_zval(ser, &zvalue, &typ);
                ION_CATCH(zend_string_release(key));
 
diff --git a/tests/unserialize/executor_globals.phpt b/tests/unserialize/executor_globals.phpt
new file mode 100644 (file)
index 0000000..5d23d17
--- /dev/null
@@ -0,0 +1,22 @@
+--TEST--
+ion\unserialize/executor_globals
+--EXTENSIONS--
+ion
+--FILE--
+TEST
+<?php
+class test_class {
+       public $s;
+       public $u;
+}
+$c = new test_class;
+$c->s = new ion\Serializer\Serializer;
+
+$c->u = new ion\Unserializer\Unserializer;
+$d = $c->s->serialize($c);
+$c->u->unserialize($d);
+?>
+DONE
+--EXPECT--
+TEST
+DONE