Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 97b4eff

Browse files
committed
ext/zlib: Fix nonnull warnings
1 parent 5ccbb96 commit 97b4eff

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

‎ext/zlib/zlib_filter.c

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -321,9 +321,9 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
321321

322322
if (filterparams) {
323323
zval *tmpzval;
324+
const HashTable *filter_params_ht = HASH_OF(filterparams);
324325

325-
if ((Z_TYPE_P(filterparams) == IS_ARRAY || Z_TYPE_P(filterparams) == IS_OBJECT) &&
326-
(tmpzval = zend_hash_str_find(HASH_OF(filterparams), "window", sizeof("window") - 1))) {
326+
if (filter_params_ht != NULL && (tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("window")))) {
327327
/* log-2 base of history window (9 - 15) */
328328
zend_long tmp = zval_get_long(tmpzval);
329329
if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 32) {
@@ -346,42 +346,49 @@ static php_stream_filter *php_zlib_filter_create(const char *filtername, zval *f
346346

347347

348348
if (filterparams) {
349-
zval *tmpzval;
350349
zend_long tmp;
351350

352351
/* filterparams can either be a scalar value to indicate compression level (shortcut method)
353352
Or can be a hash containing one or more of 'window', 'memory', and/or 'level' members. */
354353

355354
switch (Z_TYPE_P(filterparams)) {
356355
case IS_ARRAY:
357-
case IS_OBJECT:
358-
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "memory", sizeof("memory") -1))) {
356+
case IS_OBJECT: {
357+
zval *tmpzval;
358+
const HashTable *filter_params_ht = HASH_OF(filterparams);
359+
ZEND_ASSERT(filter_params_ht != NULL);
360+
361+
tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("memory"));
362+
if (tmpzval != NULL) {
359363
/* Memory Level (1 - 9) */
360364
tmp = zval_get_long(tmpzval);
361365
if (tmp < 1 || tmp > MAX_MEM_LEVEL) {
362366
php_error_docref(NULL, E_WARNING, "Invalid parameter given for memory level (" ZEND_LONG_FMT ")", tmp);
363367
} else {
364-
memLevel = tmp;
368+
memLevel = (int)tmp;
365369
}
366370
}
367371

368-
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "window", sizeof("window") - 1))) {
372+
tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("window"));
373+
if (tmpzval != NULL) {
369374
/* log-2 base of history window (9 - 15) */
370375
tmp = zval_get_long(tmpzval);
371376
if (tmp < -MAX_WBITS || tmp > MAX_WBITS + 16) {
372377
php_error_docref(NULL, E_WARNING, "Invalid parameter given for window size (" ZEND_LONG_FMT ")", tmp);
373378
} else {
374-
windowBits = tmp;
379+
windowBits = (int)tmp;
375380
}
376381
}
377382

378-
if ((tmpzval = zend_hash_str_find(HASH_OF(filterparams), "level", sizeof("level") - 1))) {
383+
tmpzval = zend_hash_str_find(filter_params_ht, ZEND_STRL("level"));
384+
if (tmpzval != NULL) {
379385
tmp = zval_get_long(tmpzval);
380386

381387
/* Pseudo pass through to catch level validating code */
382388
goto factory_setlevel;
383389
}
384390
break;
391+
}
385392
case IS_STRING:
386393
case IS_DOUBLE:
387394
case IS_LONG:

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /