Skip to content

Commit fbb09bb

Browse files
committed
Merge branch 'PHP-8.5'
* PHP-8.5: Fix memory leak in phar_parse_zipfile() error handling
2 parents cff7d9e + 7ad5146 commit fbb09bb

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
@@ -667,7 +667,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
667667
}
668668
}
669669

670-
if (!entry.uncompressed_filesize || !actual_alias) {
670+
if (!entry.uncompressed_filesize) {
671+
efree(actual_alias);
671672
php_stream_filter_remove(filter, 1);
672673
zend_string_release_ex(entry.filename, entry.is_persistent);
673674
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -700,7 +701,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
700701
}
701702
}
702703

703-
if (!entry.uncompressed_filesize || !actual_alias) {
704+
if (!entry.uncompressed_filesize) {
705+
efree(actual_alias);
704706
php_stream_filter_remove(filter, 1);
705707
zend_string_release_ex(entry.filename, entry.is_persistent);
706708
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -723,7 +725,8 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
723725
}
724726
}
725727

726-
if (!entry.uncompressed_filesize || !actual_alias) {
728+
if (!entry.uncompressed_filesize) {
729+
efree(actual_alias);
727730
zend_string_release_ex(entry.filename, entry.is_persistent);
728731
PHAR_ZIP_FAIL("unable to read in alias, truncated");
729732
}

0 commit comments

Comments
 (0)