com php-src: fix leak, take on 7.x: ext/wddx/tests/bug73631.phpt ext/wddx/wddx.c
| From: | Anatol Belski | Date: | Tue, 06 Dec 2016 15:24:12 +0000 |
| Subject: | com php-src: fix leak, take on 7.x: ext/wddx/tests/bug73631.phpt ext/wddx/wddx.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-96215@lists.php.net to get a copy of this message | ||
Commit: 7f22627870995dd16ff279a5cb8576efb8207b3c
Author: Anatol Belski <ab@php.net> Tue, 6 Dec 2016 14:42:59 +0100
Parents: 7eb7831295043afb132061a94526960941d40898
Branches: PHP-7.0.14
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=7f22627870995dd16ff279a5cb8576efb8207b3c
Log:
fix leak, take on 7.x
(cherry picked from commit 9b1430140a75698fd30b304d9bb488a2ce189750)
Changed paths:
M ext/wddx/tests/bug73631.phpt
M ext/wddx/wddx.c
Diff:
diff --git a/ext/wddx/tests/bug73631.phpt b/ext/wddx/tests/bug73631.phpt
index 880ada5..1fcde72 100644
--- a/ext/wddx/tests/bug73631.phpt
+++ b/ext/wddx/tests/bug73631.phpt
@@ -2,8 +2,6 @@
Bug #73631 (Memory leak due to invalid wddx stack processing)
--SKIPIF--
<?php if (!extension_loaded("wddx")) print "skip"; ?>
---XFAIL--
-Still has memory leaks, not sure how to fix them.
--FILE--
<?php
$xml = <<<EOF
diff --git a/ext/wddx/wddx.c b/ext/wddx/wddx.c
index 662b957..d58a564 100644
--- a/ext/wddx/wddx.c
+++ b/ext/wddx/wddx.c
@@ -907,8 +907,13 @@ static void php_wddx_pop_element(void *user_data, const XML_Char *name)
}
if (!strcmp((char *)name, EL_BINARY)) {
- zend_string *new_str = php_base64_decode(
- (unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
+ zend_string *new_str = NULL;
+
+ if (ZSTR_EMPTY_ALLOC() != Z_STR(ent1->data)) {
+ new_str = php_base64_decode(
+ (unsigned char *)Z_STRVAL(ent1->data), Z_STRLEN(ent1->data));
+ }
+
zval_ptr_dtor(&ent1->data);
if (new_str) {
ZVAL_STR(&ent1->data, new_str);