From 5d3cf577aad15b119c137a873f468c0614f2eb2e Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Thu, 11 Jun 2015 19:41:43 +0200 Subject: Make convert_to_* safe with rc>1 This only involves switching zval_dtor to zval_ptr_dtor for arrays and making the convert_to_object for arrays a bit more generic. All the other changes outside zend_operators.c just make use of this new ability (use COPY instead of DUP). What's still missing: Proper references handling. I've seen many convert_to* calls that will break when a reference is used. Also fixes bug #69788. --- ext/soap/php_encoding.c | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) (limited to 'ext/soap/php_encoding.c') diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index 96207f7975..7bff2aeab6 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -923,21 +923,16 @@ static xmlNodePtr to_xml_base64(encodeTypePtr type, zval *data, int style, xmlNo if (Z_TYPE_P(data) == IS_STRING) { str = php_base64_encode((unsigned char*)Z_STRVAL_P(data), Z_STRLEN_P(data)); - text = xmlNewTextLen(BAD_CAST(str->val), str->len); - xmlAddChild(ret, text); - zend_string_release(str); } else { - zval tmp; - - ZVAL_DUP(&tmp, data); - convert_to_string(&tmp); - str = php_base64_encode((unsigned char*)Z_STRVAL(tmp), Z_STRLEN(tmp)); - text = xmlNewTextLen(BAD_CAST(str->val), str->len); - xmlAddChild(ret, text); - zend_string_release(str); - zval_dtor(&tmp); + zend_string *tmp = zval_get_string(data); + str = php_base64_encode((unsigned char*) tmp->val, tmp->len); + zend_string_release(tmp); } + text = xmlNewTextLen(BAD_CAST(str->val), str->len); + xmlAddChild(ret, text); + zend_string_release(str); + if (style == SOAP_ENCODED) { set_ns_and_type(ret, type); } -- cgit v1.2.1