Skip to content

Commit a9dada2

Browse files
committed
Fix Soap leaking http_msg on error
Testing all cases is not so easy to do as we would need a server that redirects from e.g. http to https while SSL is not available. Closes GH-16254.
1 parent a5e8ac6 commit a9dada2

File tree

2 files changed

+11
-0
lines changed

2 files changed

+11
-0
lines changed

NEWS

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ PHP NEWS
7474
- SOAP:
7575
. Fixed bug #62900 (Wrong namespace on xsd import error message). (nielsdos)
7676
. Fixed bug GH-16237 (Segmentation fault when cloning SoapServer). (nielsdos)
77+
. Fix Soap leaking http_msg on error. (nielsdos)
7778

7879
- Standard:
7980
. Fixed bug GH-15613 (overflow on unpack call hex string repeater).

ext/soap/php_http.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -461,6 +461,7 @@ int make_http_soap_request(zval *this_ptr,
461461
}
462462
add_soap_fault(this_ptr, "HTTP", "Unable to parse URL", NULL, NULL);
463463
smart_str_free(&soap_headers_z);
464+
efree(http_msg);
464465
return FALSE;
465466
}
466467

@@ -474,6 +475,7 @@ int make_http_soap_request(zval *this_ptr,
474475
}
475476
add_soap_fault(this_ptr, "HTTP", "Unknown protocol. Only http and https are allowed.", NULL, NULL);
476477
smart_str_free(&soap_headers_z);
478+
efree(http_msg);
477479
return FALSE;
478480
}
479481

@@ -487,6 +489,7 @@ int make_http_soap_request(zval *this_ptr,
487489
add_soap_fault(this_ptr, "HTTP", "SSL support is not available in this build", NULL, NULL);
488490
PG(allow_url_fopen) = old_allow_url_fopen;
489491
smart_str_free(&soap_headers_z);
492+
efree(http_msg);
490493
return FALSE;
491494
}
492495

@@ -541,6 +544,7 @@ int make_http_soap_request(zval *this_ptr,
541544
add_soap_fault(this_ptr, "HTTP", "Could not connect to host", NULL, NULL);
542545
PG(allow_url_fopen) = old_allow_url_fopen;
543546
smart_str_free(&soap_headers_z);
547+
efree(http_msg);
544548
return FALSE;
545549
}
546550
}
@@ -684,6 +688,7 @@ int make_http_soap_request(zval *this_ptr,
684688
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
685689
smart_str_free(&soap_headers_z);
686690
smart_str_free(&soap_headers);
691+
efree(http_msg);
687692
return FALSE;
688693
}
689694

@@ -901,12 +906,14 @@ int make_http_soap_request(zval *this_ptr,
901906
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
902907
add_soap_fault(this_ptr, "HTTP", "Failed Sending HTTP SOAP request", NULL, NULL);
903908
smart_str_free(&soap_headers_z);
909+
efree(http_msg);
904910
return FALSE;
905911
}
906912
smart_str_free(&soap_headers);
907913
} else {
908914
add_soap_fault(this_ptr, "HTTP", "Failed to create stream??", NULL, NULL);
909915
smart_str_free(&soap_headers_z);
916+
efree(http_msg);
910917
return FALSE;
911918
}
912919

@@ -915,6 +922,7 @@ int make_http_soap_request(zval *this_ptr,
915922
convert_to_null(Z_CLIENT_HTTPSOCKET_P(this_ptr));
916923
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
917924
smart_str_free(&soap_headers_z);
925+
efree(http_msg);
918926
return TRUE;
919927
}
920928

@@ -929,6 +937,7 @@ int make_http_soap_request(zval *this_ptr,
929937
convert_to_null(Z_CLIENT_USE_PROXY_P(this_ptr));
930938
add_soap_fault(this_ptr, "HTTP", "Error Fetching http headers", NULL, NULL);
931939
smart_str_free(&soap_headers_z);
940+
efree(http_msg);
932941
return FALSE;
933942
}
934943

@@ -1157,6 +1166,7 @@ int make_http_soap_request(zval *this_ptr,
11571166
if (--redirect_max < 1) {
11581167
add_soap_fault(this_ptr, "HTTP", "Redirection limit reached, aborting", NULL, NULL);
11591168
smart_str_free(&soap_headers_z);
1169+
efree(http_msg);
11601170
return FALSE;
11611171
}
11621172

0 commit comments

Comments
 (0)