From 1b993c8468a0bea9eb350e4d322c75a4238ab604 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sat, 11 Oct 2025 12:56:10 +0200 Subject: [PATCH] Fix memory leak in phar_parse_zipfile() error handling --- ext/phar/zip.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/ext/phar/zip.c b/ext/phar/zip.c index dff170dc29b48..78725949d2fca 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -641,7 +641,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia } } - if (!entry.uncompressed_filesize || !actual_alias) { + if (!entry.uncompressed_filesize) { + efree(actual_alias); php_stream_filter_remove(filter, 1); pefree(entry.filename, entry.is_persistent); PHAR_ZIP_FAIL("unable to read in alias, truncated"); @@ -674,7 +675,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia } } - if (!entry.uncompressed_filesize || !actual_alias) { + if (!entry.uncompressed_filesize) { + efree(actual_alias); php_stream_filter_remove(filter, 1); pefree(entry.filename, entry.is_persistent); PHAR_ZIP_FAIL("unable to read in alias, truncated"); @@ -697,7 +699,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia } } - if (!entry.uncompressed_filesize || !actual_alias) { + if (!entry.uncompressed_filesize) { + efree(actual_alias); pefree(entry.filename, entry.is_persistent); PHAR_ZIP_FAIL("unable to read in alias, truncated"); }