Skip to content

Commit 5e58833

Browse files
committed
Merge branch 'PHP-8.3' into PHP-8.4
* PHP-8.3: phar: Fix more alias memory leaks
2 parents 390e243 + b529c77 commit 5e58833

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
@@ -30,7 +30,8 @@ PHP NEWS
3030
- Phar:
3131
. Fix memory leak of argument in webPhar. (nielsdos)
3232
. Fix memory leak when setAlias() fails. (nielsdos)
33-
. Fix memory leak in phar_parse_zipfile() error handling. (nielsdos)
33+
. Fix a bunch of memory leaks in phar_parse_zipfile() error handling.
34+
(nielsdos)
3435
. Fix file descriptor/memory leak when opening central fp fails. (nielsdos)
3536

3637
- Random:

ext/phar/zip.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -346,6 +346,7 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
346346
entry.fp_type = PHAR_FP;
347347
entry.is_persistent = mydata->is_persistent;
348348
#define PHAR_ZIP_FAIL(errmsg) \
349+
efree(actual_alias); \
349350
zend_hash_destroy(&mydata->manifest); \
350351
HT_INVALIDATE(&mydata->manifest); \
351352
zend_hash_destroy(&mydata->mounted_dirs); \
@@ -651,7 +652,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
651652
}
652653

653654
if (!entry.uncompressed_filesize) {
654-
efree(actual_alias);
655655
php_stream_filter_remove(filter, 1);
656656
pefree(entry.filename, entry.is_persistent);
657657
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -685,7 +685,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
685685
}
686686

687687
if (!entry.uncompressed_filesize) {
688-
efree(actual_alias);
689688
php_stream_filter_remove(filter, 1);
690689
pefree(entry.filename, entry.is_persistent);
691690
PHAR_ZIP_FAIL("unable to read in alias, truncated");
@@ -709,7 +708,6 @@ int phar_parse_zipfile(php_stream *fp, char *fname, size_t fname_len, char *alia
709708
}
710709

711710
if (!entry.uncompressed_filesize) {
712-
efree(actual_alias);
713711
pefree(entry.filename, entry.is_persistent);
714712
PHAR_ZIP_FAIL("unable to read in alias, truncated");
715713
}

0 commit comments

Comments
 (0)