Skip to content

Commit 810507a

Browse files
committed
http_fopen_wrapper: fix [-Wanalyzer-deref-before-check]
warning: check of ‘*resource.scheme’ for NULL after already dereferencing it [-Wanalyzer-deref-before-check] 186 | use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && ZSTR_VAL(resource->scheme)[4] == 's'; | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Although resource->scheme is already dereferenced on line 163 in the IF condition
1 parent 79128af commit 810507a

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

ext/standard/http_fopen_wrapper.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
160160
return NULL;
161161
}
162162

163+
ZEND_ASSERT(resource->scheme);
163164
if (!zend_string_equals_literal_ci(resource->scheme, "http") &&
164165
!zend_string_equals_literal_ci(resource->scheme, "https")) {
165166
if (!context ||
@@ -183,7 +184,7 @@ static php_stream *php_stream_url_wrap_http_ex(php_stream_wrapper *wrapper,
183184
return NULL;
184185
}
185186

186-
use_ssl = resource->scheme && (ZSTR_LEN(resource->scheme) > 4) && ZSTR_VAL(resource->scheme)[4] == 's';
187+
use_ssl = (ZSTR_LEN(resource->scheme) > 4) && ZSTR_VAL(resource->scheme)[4] == 's';
187188
/* choose default ports */
188189
if (use_ssl && resource->port == 0)
189190
resource->port = 443;

0 commit comments

Comments
 (0)