Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ext/zlib/tests/inflate_init_error.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@ try {

?>
--EXPECT--
Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE
inflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
2 changes: 1 addition & 1 deletion ext/zlib/tests/leak_invalid_encoding_with_dict.phpt
Original file line number Diff line number Diff line change
Expand Up @@ -16,5 +16,5 @@ try {
}
?>
--EXPECT--
Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE
inflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
deflate_init(): Argument #1 ($encoding) must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE
9 changes: 7 additions & 2 deletions ext/zlib/zlib.c
Original file line number Diff line number Diff line change
Expand Up @@ -807,12 +807,17 @@ static bool zlib_create_dictionary_string(HashTable *options, char **dict, size_
HashTable *dictionary = Z_ARR_P(option_buffer);
bool result = true;

if (!HT_IS_PACKED(dictionary)) {
zend_argument_value_error(2, "must be of type array with keys as integer");
return false;
}

if (zend_hash_num_elements(dictionary) > 0) {
zend_string **strings = safe_emalloc(zend_hash_num_elements(dictionary), sizeof(zend_string *), 0);
size_t total = 0;

zval *cur;
ZEND_HASH_FOREACH_VAL(dictionary, cur) {
ZEND_HASH_PACKED_FOREACH_VAL(dictionary, cur) {
zend_string *string = zval_try_get_string(cur);
if (string == NULL) {
result = false;
Expand Down Expand Up @@ -887,7 +892,7 @@ PHP_FUNCTION(inflate_init)
case PHP_ZLIB_ENCODING_DEFLATE:
break;
default:
zend_value_error("Encoding mode must be ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP or ZLIB_ENCODING_DEFLATE");
zend_argument_value_error(1, "must be one of ZLIB_ENCODING_RAW, ZLIB_ENCODING_GZIP, or ZLIB_ENCODING_DEFLATE");
RETURN_THROWS();
}

Expand Down