Skip to content

Commit d613c0e

Browse files
committed
Fix phpGH-16429: Segmentation fault (access null pointer) in SoapClient
If get_iterator() fails, we should not destroy the object. Also changes the check to a NULL check to be more defensive, and to match the VM. Closes phpGH-16441.
1 parent ec8a24f commit d613c0e

File tree

3 files changed

+29
-2
lines changed

3 files changed

+29
-2
lines changed

NEWS

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ PHP NEWS
5555
. Fixed bug GH-16290 (overflow on cookie_lifetime ini value).
5656
(David Carlier)
5757

58+
- SOAP:
59+
. Fixed bug GH-16429 (Segmentation fault access null pointer in SoapClient).
60+
(nielsdos)
61+
5862
- Sockets:
5963
. Fixed bug with overflow socket_recvfrom $length argument. (David Carlier)
6064

ext/soap/php_encoding.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2210,8 +2210,8 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
22102210

22112211
iter = ce->get_iterator(ce, data, 0);
22122212

2213-
if (EG(exception)) {
2214-
goto iterator_done;
2213+
if (!iter) {
2214+
goto iterator_failed_to_get;
22152215
}
22162216

22172217
if (iter->funcs->rewind) {
@@ -2251,6 +2251,7 @@ static xmlNodePtr to_xml_array(encodeTypePtr type, zval *data, int style, xmlNod
22512251
}
22522252
iterator_done:
22532253
OBJ_RELEASE(&iter->std);
2254+
iterator_failed_to_get:
22542255
if (EG(exception)) {
22552256
zval_ptr_dtor(&array_copy);
22562257
ZVAL_UNDEF(&array_copy);

ext/soap/tests/bugs/gh16429.phpt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
--TEST--
2+
GH-16429 (Segmentation fault (access null pointer) in SoapClient)
3+
--EXTENSIONS--
4+
soap
5+
--FILE--
6+
<?php
7+
function gen() {
8+
var_dump(str_repeat("x", yield));
9+
}
10+
$gen = gen();
11+
$gen->send(10);
12+
$fusion = $gen;
13+
$client = new SoapClient(__DIR__."/../interop/Round2/GroupB/round2_groupB.wsdl",array("trace"=>1,"exceptions"=>0));
14+
try {
15+
$client->echo2DStringArray($fusion);
16+
} catch (Exception $e) {
17+
echo $e->getMessage(), "\n";
18+
}
19+
?>
20+
--EXPECT--
21+
string(10) "xxxxxxxxxx"
22+
Cannot traverse an already closed generator

0 commit comments

Comments
 (0)