Skip to content

Commit 13ad8ef

Browse files
committed
memory stream: fix [-Wanalyzer-deref-before-check]
| 732 | ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0; | | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ Although mode is already dereference on line 723 in the call to strlen()
1 parent 810507a commit 13ad8ef

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

main/streams/memory.c

+4-2
Original file line numberDiff line numberDiff line change
@@ -349,7 +349,7 @@ static ssize_t php_stream_temp_write(php_stream *stream, const char *buf, size_t
349349
}
350350
if (php_stream_is(ts->innerstream, PHP_STREAM_IS_MEMORY)) {
351351
zend_off_t pos = php_stream_tell(ts->innerstream);
352-
352+
353353
if (pos + count >= ts->smax) {
354354
zend_string *membuf = php_stream_memory_get_buffer(ts->innerstream);
355355
php_stream *file = php_stream_fopen_temporary_file(ts->tmpdir, "php", NULL);
@@ -614,6 +614,8 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
614614
int base64 = 0;
615615
zend_string *base64_comma = NULL;
616616

617+
ZEND_ASSERT(mode);
618+
617619
ZVAL_NULL(&meta);
618620
if (memcmp(path, "data:", 5)) {
619621
return NULL;
@@ -729,7 +731,7 @@ static php_stream * php_stream_url_wrap_rfc2397(php_stream_wrapper *wrapper, con
729731
stream->ops = &php_stream_rfc2397_ops;
730732
ts = (php_stream_temp_data*)stream->abstract;
731733
assert(ts != NULL);
732-
ts->mode = mode && mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
734+
ts->mode = mode[0] == 'r' && mode[1] != '+' ? TEMP_STREAM_READONLY : 0;
733735
ZVAL_COPY_VALUE(&ts->meta, &meta);
734736
}
735737
if (base64_comma) {

0 commit comments

Comments
 (0)