Skip to content
Browse files

Fix bug #61097 Memory leak in xmlrpc functions copying zvals

Needs to be merged to 5.4.
  • Loading branch information...
1 parent daa190f commit bfcc199f2867efdf667dbc68a3325cf92d71d3f8 @nikic nikic committed
Showing with 23 additions and 6 deletions.
  1. +3 −0 NEWS
  2. +16 −0 ext/xmlrpc/tests/bug61097.phpt
  3. +4 −6 ext/xmlrpc/xmlrpc-epi-php.c
View
3 NEWS
@@ -54,6 +54,9 @@ PHP NEWS
. Fixed bug #61058 (array_fill leaks if start index is PHP_INT_MAX).
(Laruence)
+- XMLRPC:
+ . Fixed bug #61097 (Memory leak in xmlrpc functions copying zvals). (Nikic)
+
02 Feb 2012, PHP 5.3.10
- Core:
View
16 ext/xmlrpc/tests/bug61097.phpt
@@ -0,0 +1,16 @@
+--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);
+
+echo 'Done';
+?>
+--EXPECT--
+Done
View
10 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);

0 comments on commit bfcc199

Please sign in to comment.
Something went wrong with that request. Please try again.