Skip to content

Commit 1dd4023

Browse files
committed
ext/phar: Fix nonnull warnings
1 parent b476591 commit 1dd4023

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

ext/phar/stream.c

+22-16
Original file line numberDiff line numberDiff line change
@@ -209,23 +209,29 @@ static php_stream * phar_wrapper_open_url(php_stream_wrapper *wrapper, const cha
209209
php_url_free(resource);
210210
efree(internal_file);
211211

212-
if (context && Z_TYPE(context->options) != IS_UNDEF && (pzoption = zend_hash_str_find(HASH_OF(&context->options), "phar", sizeof("phar")-1)) != NULL) {
213-
pharcontext = HASH_OF(pzoption);
214-
if (idata->internal_file->uncompressed_filesize == 0
215-
&& idata->internal_file->compressed_filesize == 0
216-
&& (pzoption = zend_hash_str_find(pharcontext, "compress", sizeof("compress")-1)) != NULL
217-
&& Z_TYPE_P(pzoption) == IS_LONG
218-
&& (Z_LVAL_P(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
219-
) {
220-
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
221-
idata->internal_file->flags |= Z_LVAL_P(pzoption);
222-
}
223-
if ((pzoption = zend_hash_str_find(pharcontext, "metadata", sizeof("metadata")-1)) != NULL) {
224-
phar_metadata_tracker_free(&idata->internal_file->metadata_tracker, idata->internal_file->is_persistent);
212+
if (context && !Z_ISUNDEF(context->options)) {
213+
const HashTable *options_ht = HASH_OF(&context->options);
214+
ZEND_ASSERT(options_ht != NULL);
215+
216+
pzoption = zend_hash_str_find(options_ht, ZEND_STRL("phar"));
217+
if (pzoption != NULL) {
218+
pharcontext = HASH_OF(pzoption);
219+
if (idata->internal_file->uncompressed_filesize == 0
220+
&& idata->internal_file->compressed_filesize == 0
221+
&& (pzoption = zend_hash_str_find(pharcontext, "compress", sizeof("compress")-1)) != NULL
222+
&& Z_TYPE_P(pzoption) == IS_LONG
223+
&& (Z_LVAL_P(pzoption) & ~PHAR_ENT_COMPRESSION_MASK) == 0
224+
) {
225+
idata->internal_file->flags &= ~PHAR_ENT_COMPRESSION_MASK;
226+
idata->internal_file->flags |= Z_LVAL_P(pzoption);
227+
}
228+
if ((pzoption = zend_hash_str_find(pharcontext, "metadata", sizeof("metadata")-1)) != NULL) {
229+
phar_metadata_tracker_free(&idata->internal_file->metadata_tracker, idata->internal_file->is_persistent);
225230

226-
metadata = pzoption;
227-
ZVAL_COPY_DEREF(&idata->internal_file->metadata_tracker.val, metadata);
228-
idata->phar->is_modified = 1;
231+
metadata = pzoption;
232+
ZVAL_COPY_DEREF(&idata->internal_file->metadata_tracker.val, metadata);
233+
idata->phar->is_modified = 1;
234+
}
229235
}
230236
}
231237
if (opened_path) {

0 commit comments

Comments
 (0)