mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
zlib_create_dictionary_string() allocates memory, so we can leak memory if there's an early exit before the assignment to the return value. Solve this by moving all validation upwards. Closes GH-17788.
21 lines
548 B
PHP
21 lines
548 B
PHP
--TEST--
|
|
Memory leak when passing a dictionary with invalid encoding
|
|
--EXTENSIONS--
|
|
zlib
|
|
--FILE--
|
|
<?php
|
|
try {
|
|
inflate_init(123456, ["dictionary" => "dict"]);
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
try {
|
|
deflate_init(123456, ["dictionary" => "dict"]);
|
|
} catch (ValueError $e) {
|
|
echo $e->getMessage(), "\n";
|
|
}
|
|
?>
|
|
--EXPECT--
|
|
Encoding mode must be 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
|