com php-src: Avoid uninit warnin in http_fopen_wrapper: ext/standard/http_fopen_wrapper.c
| From: | Nikita Popov | Date: | Fri, 12 Apr 2019 13:12:39 +0000 |
| Subject: | com php-src: Avoid uninit warnin in http_fopen_wrapper: ext/standard/http_fopen_wrapper.c | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-105697@lists.php.net to get a copy of this message | ||
Commit: b6b98bdf641c9d054638c60ec9bb3199d3164303
Author: Nikita Popov <nikita.ppv@gmail.com> Fri, 12 Apr 2019 15:00:55 +0200
Parents: e1ab68622815050dfb6ed3f927c438906c2569b9
Branches: PHP-7.4 master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=b6b98bdf641c9d054638c60ec9bb3199d3164303
Log:
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.
Changed paths:
M ext/standard/http_fopen_wrapper.c
Diff:
diff --git a/ext/standard/http_fopen_wrapper.c b/ext/standard/http_fopen_wrapper.c
index 611cbcc..b01aed1 100644
--- a/ext/standard/http_fopen_wrapper.c
+++ b/ext/standard/http_fopen_wrapper.c
@@ -661,11 +661,11 @@ finish:
array_init(response_header);
}
- if (!php_stream_eof(stream)) {
- size_t tmp_line_len;
+ {
/* get response header */
-
- if (php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
+ size_t tmp_line_len;
+ if (!php_stream_eof(stream) &&
+ php_stream_get_line(stream, tmp_line, sizeof(tmp_line) - 1, &tmp_line_len) != NULL) {
zval http_response;
if (tmp_line_len > 9) {
@@ -726,10 +726,10 @@ finish:
}
ZVAL_STRINGL(&http_response, tmp_line, tmp_line_len);
zend_hash_next_index_insert(Z_ARRVAL_P(response_header), &http_response);
+ } else {
+ php_stream_wrapper_log_error(wrapper, options, "HTTP request failed, unexpected end of
socket!");
+ goto out;
}
- } else {
- php_stream_wrapper_log_error(wrapper, options, "HTTP request failed, unexpected end of
socket!");
- goto out;
}
/* read past HTTP headers */