diff --git a/NEWS b/NEWS index c20ed1e0065..82be193695b 100644 --- a/NEWS +++ b/NEWS @@ -97,6 +97,8 @@ PHP NEWS . Fix Soap leaking http_msg on error. (nielsdos) . Fixed bug GH-16256 (Assertion failure in ext/soap/php_encoding.c:460). (nielsdos) + . Fixed bug GH-16259 (Soap segfault when classmap instantiation fails). + (nielsdos) - SPL: . Fixed bug GH-15918 (Assertion failure in ext/spl/spl_fixedarray.c). diff --git a/ext/soap/php_encoding.c b/ext/soap/php_encoding.c index fda34b080e3..5244b83e42c 100644 --- a/ext/soap/php_encoding.c +++ b/ext/soap/php_encoding.c @@ -1444,7 +1444,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z return ret; } - object_init_ex(ret, ce); + if (object_init_ex(ret, ce) != SUCCESS) { + return ret; + } master_to_zval_int(&base, enc, data); set_zval_property(ret, "_", &base); } else { @@ -1453,7 +1455,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z if (soap_check_xml_ref(ret, data)) { return ret; } - object_init_ex(ret, ce); + if (object_init_ex(ret, ce) != SUCCESS) { + return ret; + } soap_add_xml_ref(ret, data); } } else if (sdlType->kind == XSD_TYPEKIND_EXTENSION && @@ -1498,7 +1502,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z return ret; } - object_init_ex(ret, ce); + if (object_init_ex(ret, ce) != SUCCESS) { + return ret; + } soap_add_xml_ref(ret, data); master_to_zval_int(&base, sdlType->encode, data); set_zval_property(ret, "_", &base); @@ -1509,7 +1515,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z if (soap_check_xml_ref(ret, data)) { return ret; } - object_init_ex(ret, ce); + if (object_init_ex(ret, ce) != SUCCESS) { + return ret; + } soap_add_xml_ref(ret, data); } if (sdlType->model) { @@ -1569,7 +1577,9 @@ static zval *to_zval_object_ex(zval *ret, encodeTypePtr type, xmlNodePtr data, z return ret; } - object_init_ex(ret, ce); + if (object_init_ex(ret, ce) != SUCCESS) { + return ret; + } soap_add_xml_ref(ret, data); trav = data->children; diff --git a/ext/soap/tests/bugs/gh16259.phpt b/ext/soap/tests/bugs/gh16259.phpt new file mode 100644 index 00000000000..dd7e0e1585d --- /dev/null +++ b/ext/soap/tests/bugs/gh16259.phpt @@ -0,0 +1,23 @@ +--TEST-- +GH-16259 (Soap segfault when classmap instantiation fails) +--EXTENSIONS-- +soap +--FILE-- + "CT_A1", "A2" => "CT_A2"); +$client = new SoapClient(__DIR__."/bug36575.wsdl", array("trace" => 1, "exceptions" => 0)); +$a2 = new CT_A2(); +$client->test($a2); +$soapRequest = $client->__getLastRequest(); + +$server = new SoapServer(__DIR__."/bug36575.wsdl", array("classmap" => $classMap)); +$server->handle($soapRequest); +?> +--EXPECT-- + +SOAP-ENV:ServerCannot instantiate abstract class CT_A1