Skip to content

Commit b6b98bd

Browse files
committed
Avoid uninit warnin in http_fopen_wrapper
This one looks semi-legit, in case php_stream_eof() returns false but php_stream_get_line() fails. Not totally sure this cannot happen, so rewriting to check both conditions at once.
1 parent e1ab686 commit b6b98bd

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

ext/standard/http_fopen_wrapper.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -661,11 +661,11 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
661661
array_init(response_header);
662662
}
663663

664-
if (!php_stream_eof(stream)) {
665-
size_t tmp_line_len;
664+
{
666665
/* get response header */
667-
668-
if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
666+
size_t tmp_line_len;
667+
if (!php_stream_eof(stream) &&
668+
php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
669669
zval http_response;
670670

671671
if (tmp_line_len > 9) {
@@ -726,10 +726,10 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
726726
}
727727
ZVAL_STRINGL(&http_response, tmp_line, tmp_line_len);
728728
zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response);
729+
} else {
730+
php_stream_wrapper_log_error(wrapper, options, "HTTP request failed, unexpected end of socket!");
731+
goto out;
729732
}
730-
} else {
731-
php_stream_wrapper_log_error(wrapper, options, "HTTP request failed, unexpected end of socket!");
732-
goto out;
733733
}
734734

735735
/* read past HTTP headers */

0 commit comments

Comments
 (0)