Skip to content

Commit 17f6752

Browse files
committed
zip: Fix leak when zip_fread() fails
Closes GH-22238.
1 parent c4d4cea commit 17f6752

2 files changed

Lines changed: 4 additions & 0 deletions

File tree

NEWS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@ PHP NEWS
3131
(ndossche)
3232
. Fixed memory leak in inflate_add(). (ndossche)
3333

34+
- Zip:
35+
. Fixed error-related memory leaks. (ndossche)
36+
3437
04 Jun 2026, PHP 8.4.22
3538

3639
- Date:

ext/zip/php_zip.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2962,6 +2962,7 @@ static void php_zip_get_from(INTERNAL_FUNCTION_PARAMETERS, int type) /* {{{ */
29622962
buffer = zend_string_safe_alloc(1, len, 0, 0);
29632963
zip_int64_t n = zip_fread(zf, ZSTR_VAL(buffer), ZSTR_LEN(buffer));
29642964
if (n < 1) {
2965+
zip_fclose(zf);
29652966
zend_string_efree(buffer);
29662967
RETURN_EMPTY_STRING();
29672968
}

0 commit comments

Comments
 (0)