Skip to content

Commit bbb8d07

Browse files
committed
init
1 parent 0366899 commit bbb8d07

4 files changed

Lines changed: 23 additions & 5 deletions

File tree

NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,5 +207,7 @@ PHP NEWS
207207
. deflate_init() now raises a TypeError when the value for option
208208
"level", "memory", "window", or "strategy" is not of type int.
209209
(Weilin Du)
210+
. inflate_init() now raises a TypeError when the value for option
211+
"window" is not of type int. (Weilin Du)
210212

211213
<<< NOTE: Insert NEWS from last stable release here prior to actual release! >>>

UPGRADING

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,8 @@ PHP 8.6 UPGRADE NOTES
104104
- Zlib:
105105
. deflate_init() now raises a TypeError when the value for option
106106
"level", "memory", "window", or "strategy" is not of type int.
107+
. inflate_init() now raises a TypeError when the value for option
108+
"window" is not of type int.
107109

108110
========================================
109111
2. New Features
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--TEST--
2+
inflate_init(): window option type validation
3+
--EXTENSIONS--
4+
zlib
5+
--FILE--
6+
<?php
7+
8+
try {
9+
inflate_init(ZLIB_ENCODING_DEFLATE, ['window' => []]);
10+
} catch (TypeError $e) {
11+
echo $e->getMessage(), PHP_EOL;
12+
}
13+
14+
?>
15+
--EXPECT--
16+
inflate_init(): Argument #2 ($options) the value for option "window" must be of type int, array given

ext/zlib/zlib.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -885,16 +885,14 @@ PHP_FUNCTION(inflate_init)
885885
zend_long encoding, window = 15;
886886
char *dict = NULL;
887887
size_t dictlen = 0;
888-
HashTable *options = NULL;
889-
zval *option_buffer;
888+
HashTable *options = (HashTable *) &zend_empty_array;
890889

891890
if (SUCCESS != zend_parse_parameters(ZEND_NUM_ARGS(), "l|H", &encoding, &options)) {
892891
RETURN_THROWS();
893892
}
894893

895-
if (options && (option_buffer = zend_hash_str_find(options, ZEND_STRL("window"))) != NULL) {
896-
ZVAL_DEINDIRECT(option_buffer);
897-
window = zval_get_long(option_buffer);
894+
if (!zlib_get_long_option(options, ZEND_STRL("window"), &window)) {
895+
RETURN_THROWS();
898896
}
899897
if (window < 8 || window > 15) {
900898
zend_value_error("zlib window size (logarithm) (" ZEND_LONG_FMT ") must be within 8..15", window);

0 commit comments

Comments
 (0)