mirror of
https://github.com/php/php-src.git
synced 2026-03-24 00:02:20 +01:00
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: Fix memory leak when encoding check fails
This commit is contained in:
1
NEWS
1
NEWS
@@ -55,6 +55,7 @@ PHP NEWS
|
||||
- Zlib:
|
||||
. Fixed bug GH-17745 (zlib extension incorrectly handles object arguments).
|
||||
(nielsdos)
|
||||
. Fix memory leak when encoding check fails. (nielsdos)
|
||||
|
||||
30 Jan 2025, PHP 8.4.4
|
||||
|
||||
|
||||
20
ext/zlib/tests/leak_invalid_encoding_with_dict.phpt
Normal file
20
ext/zlib/tests/leak_invalid_encoding_with_dict.phpt
Normal file
@@ -0,0 +1,20 @@
|
||||
--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
|
||||
@@ -878,10 +878,6 @@ PHP_FUNCTION(inflate_init)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (!zlib_create_dictionary_string(options, &dict, &dictlen)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
switch (encoding) {
|
||||
case PHP_ZLIB_ENCODING_RAW:
|
||||
case PHP_ZLIB_ENCODING_GZIP:
|
||||
@@ -892,6 +888,10 @@ PHP_FUNCTION(inflate_init)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (!zlib_create_dictionary_string(options, &dict, &dictlen)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
object_init_ex(return_value, inflate_context_ce);
|
||||
ctx = Z_INFLATE_CONTEXT_P(return_value);
|
||||
|
||||
@@ -1131,10 +1131,6 @@ PHP_FUNCTION(deflate_init)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (!zlib_create_dictionary_string(options, &dict, &dictlen)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
switch (encoding) {
|
||||
case PHP_ZLIB_ENCODING_RAW:
|
||||
case PHP_ZLIB_ENCODING_GZIP:
|
||||
@@ -1145,6 +1141,10 @@ PHP_FUNCTION(deflate_init)
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
if (!zlib_create_dictionary_string(options, &dict, &dictlen)) {
|
||||
RETURN_THROWS();
|
||||
}
|
||||
|
||||
object_init_ex(return_value, deflate_context_ce);
|
||||
ctx = Z_DEFLATE_CONTEXT_P(return_value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user