Skip to content

Commit 7ad5146

Browse files
committed
Merge branch 'PHP-8.4' into PHP-8.5
* PHP-8.4: Fix memory leak in phar_parse_zipfile() error handling
2 parents 0b231c4 + 29bfb43 commit 7ad5146

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

ext/phar/zip.c

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
674674
}
675675
}
676676

677-
if (!entry.uncompressed_filesize || !actual_alias) {
677+
if (!entry.uncompressed_filesize) {
678+
efree(actual_alias);
678679
php_stream_filter_remove(filter, 1);
679680
zend_string_release_ex(entry.filename, entry.is_persistent);
680681
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -707,7 +708,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
707708
}
708709
}
709710

710-
if (!entry.uncompressed_filesize || !actual_alias) {
711+
if (!entry.uncompressed_filesize) {
712+
efree(actual_alias);
711713
php_stream_filter_remove(filter, 1);
712714
zend_string_release_ex(entry.filename, entry.is_persistent);
713715
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -730,7 +732,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
730732
}
731733
}
732734

733-
if (!entry.uncompressed_filesize || !actual_alias) {
735+
if (!entry.uncompressed_filesize) {
736+
efree(actual_alias);
734737
zend_string_release_ex(entry.filename, entry.is_persistent);
735738
PHAR_ZIP_FAIL("unable to read in alias, truncated");
736739
}

0 commit comments

Comments
 (0)