1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Merge branch 'PHP-8.3' into PHP-8.4

* PHP-8.3:
  phar: Fix memory leaks when creating temp file fails when applying zip signature
This commit is contained in:
Niels Dossche
2025-10-05 21:11:03 +02:00
2 changed files with 7 additions and 2 deletions

2
NEWS
View File

@@ -44,6 +44,8 @@ PHP NEWS
- Phar:
. Fix memory leak and invalid continuation after tar header writing fails.
(nielsdos)
. Fix memory leaks when creating temp file fails when applying zip signature.
(nielsdos)
- SimpleXML:
. Fixed bug GH-19988 (zend_string_init with NULL pointer in simplexml (UB)).

View File

@@ -1223,7 +1223,9 @@ static int phar_zip_applysignature(phar_archive_data *phar, struct _phar_zip_pas
entry.fp_type = PHAR_MOD;
entry.is_modified = 1;
if (entry.fp == NULL) {
efree(signature);
spprintf(pass->error, 0, "phar error: unable to create temporary file for signature");
php_stream_close(newfile);
return FAILURE;
}
@@ -1441,11 +1443,12 @@ fperror:
phar_metadata_tracker_try_ensure_has_serialized_data(&phar->metadata_tracker, phar->is_persistent);
if (temperr) {
temperror:
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: %s", phar->fname, temperr);
}
efree(temperr);
temperror:
notemperror:
php_stream_close(pass.centralfp);
nocentralerror:
php_stream_close(pass.filefp);
@@ -1473,7 +1476,7 @@ nocentralerror:
if (error) {
spprintf(error, 4096, "phar zip flush of \"%s\" failed: unable to write central-directory", phar->fname);
}
goto temperror;
goto notemperror;
}
}