#37850 [Opn]: Reference counting bug in SoapClient::__setSoapHeaders()

From: Date: Mon, 19 Jun 2006 18:00:08 +0000
Subject: #37850 [Opn]: Reference counting bug in SoapClient::__setSoapHeaders()
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-98511@lists.php.net to get a copy of this message
ID: 37850 User updated by: jeremiahh at allstardirectories dot com Reported By: jeremiahh at allstardirectories dot com Status: Open Bug Type: SOAP related Operating System: Linux PHP Version: 5.1.4 New Comment: It is important to note that this bug only seems to happen in the case where a single SoapHeader object is passed to __setSoapHeaders(). If you pass an array of SoapHeaders, such as array(soapHeaderObj) then the problem is non-existent. When you pass it in an array the reference counting happens automatically by the array constructor. Also, this problem does not exist in the SoapHeader()::__call method which correctly adds a reference when a single SoapHeader object is passed: ZVAL_ADDREF(headers); Previous Comments: ------------------------------------------------------------------------ [2006-06-19 17:46:03] jeremiahh at allstardirectories dot com Description: ------------ The undocumented method SoapClient::__setSoapHeaders() incorrectly handles reference counting when a single SoapHeader object is passed. Reproduce code: --------------- function someMethod() { $headers = new SoapHeader(...); $client = new SoapClient(...); $client->__setSoapHeaders($headers); $this->saved_client = $client; } function someOtherMethod() { $client = $this->saved_client; $client->__soapCall(...); } Expected result: ---------------- For the code $obj->someMethod(); $obj->someOtherMethod(); you would expect the call $client->__soapCall() to succeed with the appropriate soap headers. Actual result: -------------- It crashes. If one does a print_r($this->saved_client) in both methods the problem is obvious. The reference count for $headers is not incremented in __setSoapHeaders() and so when someMethod() finished the object is destroyed while the SoapClient object is still referencing it. Then in someOtherMethod() the SoapHeader object is no longer available. ------------------------------------------------------------------------ -- Edit this bug report at http://bugs.php.net/?id=37850&edit=1

« previous php.bugs (#98511) next »