php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #61097
Patch xmlrpc.patch revision 2012-02-15 18:20 UTC by nikic@php.net

Patch xmlrpc.patch for XMLRPC-EPI related Bug #61097

Patch version 2012-02-15 18:20 UTC

Return to Bug #61097 | Download this patch
Patch Revisions:

Developer: nikic@php.net

diff --git a/ext/xmlrpc/tests/bug61097.phpt b/ext/xmlrpc/tests/bug61097.phpt
new file mode 100644
index 0000000..1bd7aea
--- /dev/null
+++ b/ext/xmlrpc/tests/bug61097.phpt
@@ -0,0 +1,13 @@
+--TEST--
+Bug #61097 (Memory leak in xmlrpc functions copying zvals)
+--SKIPIF--
+<?php if (!extension_loaded("xmlrpc")) print "skip"; ?>
+--FILE--
+<?php
+$server = xmlrpc_server_create();
+
+$method = 'abc';
+xmlrpc_server_register_introspection_callback($server, $method);
+xmlrpc_server_register_method($server, 'abc', $method);
+?>
+--EXPECT--
diff --git a/ext/xmlrpc/xmlrpc-epi-php.c b/ext/xmlrpc/xmlrpc-epi-php.c
index 7fb97d2..13886c7 100644
--- a/ext/xmlrpc/xmlrpc-epi-php.c
+++ b/ext/xmlrpc/xmlrpc-epi-php.c
@@ -1043,9 +1043,8 @@ PHP_FUNCTION(xmlrpc_server_register_method)
 		 */
 		if (XMLRPC_ServerRegisterMethod(server->server_ptr, method_key, php_xmlrpc_callback)) {
 			/* save for later use */
-			MAKE_STD_ZVAL(method_name_save);
-			*method_name_save = **method_name;
-			zval_copy_ctor(method_name_save);
+			ALLOC_ZVAL(method_name_save);
+			MAKE_COPY_ZVAL(method_name, method_name_save);
 
 			/* register our php method */
 			add_zval(server->method_map, method_key, &method_name_save);
@@ -1073,9 +1072,8 @@ PHP_FUNCTION(xmlrpc_server_register_introspection_callback)
 
 	if (type == le_xmlrpc_server) {
 		/* save for later use */
-		MAKE_STD_ZVAL(method_name_save);
-		*method_name_save = **method_name;
-		zval_copy_ctor(method_name_save);
+		ALLOC_ZVAL(method_name_save);
+		MAKE_COPY_ZVAL(method_name, method_name_save);
 
 		/* register our php method */
 		add_zval(server->introspection_map, NULL, &method_name_save);
 
PHP Copyright © 2001-2014 The PHP Group
All rights reserved.
Last updated: Wed Apr 16 10:02:09 2014 UTC