]> granicus.if.org Git - php/commitdiff
- Fixed bug #47818 (Segfault due to bound callback param)
authorFelipe Pena <felipe@php.net>
Thu, 2 Apr 2009 15:52:26 +0000 (15:52 +0000)
committerFelipe Pena <felipe@php.net>
Thu, 2 Apr 2009 15:52:26 +0000 (15:52 +0000)
ext/xmlrpc/tests/bug47818.phpt [new file with mode: 0644]
ext/xmlrpc/xmlrpc-epi-php.c

diff --git a/ext/xmlrpc/tests/bug47818.phpt b/ext/xmlrpc/tests/bug47818.phpt
new file mode 100644 (file)
index 0000000..57e1090
--- /dev/null
@@ -0,0 +1,39 @@
+--TEST--
+Bug #47818 (Segfault due to bound callback param)
+--FILE--
+<?php
+
+class MyXmlRpc {
+    private $s;
+    private $method;
+
+    function impl($method_name, $params, $user_data){
+        $this->method = $method_name;
+        print "Inside impl(): {$this->method}\n";
+        return array_sum($params);
+    }
+
+    function __construct() {
+        $this->s = xmlrpc_server_create();
+        xmlrpc_server_register_method($this->s, 'add', array($this, 'impl'));
+    }
+
+    function call($req) {
+        return xmlrpc_server_call_method($this->s, $req, null);
+    }
+
+    function getMethod() {return $this->method;}
+
+}
+
+$x = new MyXmlRpc;
+$resp = $x->call(xmlrpc_encode_request('add', array(1, 2, 3)));
+
+$method = $x->getMethod();
+
+print "Global scope: $method\n";
+
+?>
+--EXPECTF--
+Inside impl(): add
+Global scope: add
index 0fd448b3148f963595e719d1b4e19950b91d95b6..d0f1fa573c81cec50444fa215a3fac56876d1a89 100644 (file)
@@ -1163,8 +1163,8 @@ PHP_FUNCTION(xmlrpc_server_call_method)
                        }
 
                        /* cleanup after ourselves.  what a sty! */
-                       zval_dtor(data.xmlrpc_method);
-                       FREE_ZVAL(data.xmlrpc_method);
+                       zval_ptr_dtor(&data.xmlrpc_method);
+
                        zval_dtor(data.return_data);
                        FREE_ZVAL(data.return_data);