Skip to content

Commit a544b8b

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

1 file changed

Lines changed: 2 additions & 0 deletions

File tree

ext/zlib/zlib.c

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

931931
if (inflateInit2(&ctx->Z, encoding) != Z_OK) {
932+
efree(dict);
932933
zval_ptr_dtor(return_value);
933934
php_error_docref(NULL, E_WARNING, "Failed allocating zlib.inflate context");
934935
RETURN_FALSE;
@@ -1174,6 +1175,7 @@ PHP_FUNCTION(deflate_init)
11741175
}
11751176

11761177
if (deflateInit2(&ctx->Z, level, Z_DEFLATED, encoding, memory, strategy) != Z_OK) {
1178+
efree(dict);
11771179
zval_ptr_dtor(return_value);
11781180
php_error_docref(NULL, E_WARNING, "Failed allocating zlib.deflate context");
11791181
RETURN_FALSE;

0 commit comments

Comments
 (0)