]> granicus.if.org Git - php/commitdiff
Fix bug #72860: wddx_deserialize use-after-free
authorStanislav Malyshev <stas@php.net>
Tue, 6 Sep 2016 06:42:31 +0000 (23:42 -0700)
committerStanislav Malyshev <stas@php.net>
Tue, 13 Sep 2016 04:04:23 +0000 (21:04 -0700)
ext/wddx/tests/bug72860.phpt [new file with mode: 0644]
ext/wddx/wddx.c

diff --git a/ext/wddx/tests/bug72860.phpt b/ext/wddx/tests/bug72860.phpt
new file mode 100644 (file)
index 0000000..6385457
--- /dev/null
@@ -0,0 +1,27 @@
+--TEST--
+Bug #72860: wddx_deserialize use-after-free
+--SKIPIF--
+<?php
+if (!extension_loaded('wddx')) {
+    die('skip. wddx not available');
+}
+?>
+--FILE--
+<?php
+
+$xml=<<<XML
+<?xml version='1.0'?>
+<!DOCTYPE wddxPacket SYSTEM 'wddx_0100.dtd'>
+<wddxPacket version='1.0'>
+       <recordset fieldNames='F'>
+               <field name='F'>
+       </recordset>
+</wddxPacket>
+XML;
+
+var_dump(wddx_deserialize($xml));
+?>
+DONE
+--EXPECT--
+NULL
+DONE
\ No newline at end of file
index d7bd295832c70aba70b1632cf0b6e5291f5200ae..b02d2f07ded469c5ed8256e422428d3ce8bee637 100644 (file)
@@ -230,7 +230,8 @@ static int wddx_stack_destroy(wddx_stack *stack)
 
        if (stack->elements) {
                for (i = 0; i < stack->top; i++) {
-                       if (((st_entry *)stack->elements[i])->data)     {
+                       if (((st_entry *)stack->elements[i])->data
+                                       && ((st_entry *)stack->elements[i])->type != ST_FIELD)  {
                                zval_ptr_dtor(&((st_entry *)stack->elements[i])->data);
                        }
                        if (((st_entry *)stack->elements[i])->varname) {