Skip to content

Commit b529c77

Browse files
committed
phar: Fix more alias memory leaks
Closes phpGH-20154.
1 parent 8e0504c commit b529c77

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

NEWS

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,8 @@ PHP NEWS
2828
- Phar:
2929
. Fix memory leak of argument in webPhar. (nielsdos)
3030
. Fix memory leak when setAlias() fails. (nielsdos)
31-
. Fix memory leak in phar_parse_zipfile() error handling. (nielsdos)
31+
. Fix a bunch of memory leaks in phar_parse_zipfile() error handling.
32+
(nielsdos)
3233
. Fix file descriptor/memory leak when opening central fp fails. (nielsdos)
3334

3435
- Random:

ext/phar/zip.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
314314
entry.fp_type = PHAR_FP;
315315
entry.is_persistent = mydata->is_persistent;
316316
#define PHAR_ZIP_FAIL(errmsg) \
317+
efree(actual_alias); \
317318
zend_hash_destroy(&mydata->manifest); \
318319
HT_INVALIDATE(&mydata->manifest); \
319320
zend_hash_destroy(&mydata->mounted_dirs); \
@@ -619,7 +620,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
619620
}
620621

621622
if (!entry.uncompressed_filesize) {
622-
efree(actual_alias);
623623
php_stream_filter_remove(filter, 1);
624624
pefree(entry.filename, entry.is_persistent);
625625
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -653,7 +653,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
653653
}
654654

655655
if (!entry.uncompressed_filesize) {
656-
efree(actual_alias);
657656
php_stream_filter_remove(filter, 1);
658657
pefree(entry.filename, entry.is_persistent);
659658
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -677,7 +676,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
677676
}
678677

679678
if (!entry.uncompressed_filesize) {
680-
efree(actual_alias);
681679
pefree(entry.filename, entry.is_persistent);
682680
PHAR_ZIP_FAIL("unable to read in alias, truncated");
683681
}

0 commit comments

Comments
 (0)