Fix bug #61097 Memory leak in xmlrpc functions copying zvals

Needs to be merged to 5.4.
This commit is contained in:
Nikita Popov 2012-02-18 14:58:19 +00:00
parent daa190f8fd
commit bfcc199f28
3 changed files with 23 additions and 6 deletions

3
NEWS
View File

@ -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 File

@ -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 File

@ -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);