Commit 98a644c02da for php.net
commit 98a644c02daf208fb14780f973523c4144b59b98
Author: ndossche <7771979+ndossche@users.noreply.github.com>
Date: Sat Jun 6 10:33:55 2026 +0200
zlib: no need to free dict on inflate init error
This was introduced in b0ef5fcaa17c2c3b7c48cfd4665eb1b7e8be272c because
it added `efree(dict)` to both inflate and deflate error handling.
But this is only necessary for the deflate case, not the inflate case
(as also shown in the original leak report).
diff --git a/ext/zlib/zlib.c b/ext/zlib/zlib.c
index 916fd100cc4..514e6664b72 100644
--- a/ext/zlib/zlib.c
+++ b/ext/zlib/zlib.c
@@ -908,7 +908,7 @@ PHP_FUNCTION(inflate_init)
}
if (inflateInit2(&ctx->Z, encoding) != Z_OK) {
- efree(dict);
+ /* dict is stored in the ctx in the object and will thus be freed by zval_ptr_dtor(). */
zval_ptr_dtor(return_value);
php_error_docref(NULL, E_WARNING, "Failed allocating zlib.inflate context");
RETURN_FALSE;