Skip to content

Commit ba9dfa7

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: zlib: fix memory leak if deflate initialization fails and there is a dict
2 parents 8e3befd + b0ef5fc commit ba9dfa7

2 files changed

Lines changed: 5 additions & 0 deletions

File tree

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ PHP NEWS
22
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
33
?? ??? ????, PHP 8.5.8
44

5+
- Zlib:
6+
. Fixed memory leak if deflate initialization fails and there is a dict.
7+
(ndossche)
58

69
02 Jun 2026, PHP 8.5.7
710

ext/zlib/zlib.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -911,6 +911,7 @@ PHP_FUNCTION(inflate_init)
911911
}
912912

913913
if (inflateInit2(&ctx->Z, encoding) != Z_OK) {
914+
efree(dict);
914915
zval_ptr_dtor(return_value);
915916
php_error_docref(NULL, E_WARNING, "Failed allocating zlib.inflate context");
916917
RETURN_FALSE;
@@ -1161,6 +1162,7 @@ PHP_FUNCTION(deflate_init)
11611162
}
11621163

11631164
if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) {
1165+
efree(dict);
11641166
zval_ptr_dtor(return_value);
11651167
php_error_docref(NULL, E_WARNING, "Failed allocating zlib.deflate context");
11661168
RETURN_FALSE;

0 commit comments

Comments
 (0)