]> granicus.if.org Git - php/commitdiff
Fix bug #72750: wddx_deserialize null dereference
authorStanislav Malyshev <stas@php.net>
Sun, 7 Aug 2016 23:26:52 +0000 (16:26 -0700)
committerAnatol Belski <ab@php.net>
Tue, 16 Aug 2016 11:13:05 +0000 (13:13 +0200)
(cherry picked from commit 6930a1d12c47aa1d2675837852910d177b0ceb11)

Conflicts:
ext/wddx/wddx.c

ext/wddx/tests/bug72750.phpt [new file with mode: 0644]
ext/wddx/wddx.c

diff --git a/ext/wddx/tests/bug72750.phpt b/ext/wddx/tests/bug72750.phpt
new file mode 100644 (file)
index 0000000..3a6794d
--- /dev/null
@@ -0,0 +1,34 @@
+--TEST--
+Bug #72750: wddx_deserialize null dereference
+--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'>
+<header/>
+        <data>
+                <struct>
+                     <var name='aBinary'>
+                         <binary length='11'>\\tYmluYXJRhdGE=</binary>
+                     </var>
+                 </struct>
+        </data>
+</wddxPacket>
+XML;
+
+$array = wddx_deserialize($xml);
+var_dump($array);
+?>
+--EXPECT--
+array(1) {
+  ["aBinary"]=>
+  string(0) ""
+}
index 11cf0be62e30c71f1427a6b0f7b49802ebca9f25..40b41ba373c0c374ff6bb91c660d54188c549fd7 100644 (file)
@@ -897,7 +897,11 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
                        zend_string *new_str = php_base64_decode(
                                (unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
                        zval_ptr_dtor(&ent1->data);
-                       ZVAL_STR(&ent1->data, new_str);
+                       if (new_str) {
+                               ZVAL_STR(&ent1->data, new_str);
+                       } else {
+                               ZVAL_EMPTY_STRING(&ent1->data);
+                       }
                }
 
                /* Call __wakeup() method on the object. */