From c89f25bf6902bb97c981c2b5e7012b557f44e9ed Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 12 Oct 2025 12:57:49 +0200 Subject: [PATCH] phar: Fix file descriptor/memory leak when opening central fp fails Closes GH-20145. --- NEWS | 1 + ext/phar/zip.c | 1 + 2 files changed, 2 insertions(+) diff --git a/NEWS b/NEWS index b06b1bf300b..8412c6c2bf4 100644 --- a/NEWS +++ b/NEWS @@ -23,6 +23,7 @@ PHP NEWS . Fix memory leak of argument in webPhar. (nielsdos) . Fix memory leak when setAlias() fails. (nielsdos) . Fix memory leak in phar_parse_zipfile() error handling. (nielsdos) + . Fix file descriptor/memory leak when opening central fp fails. (nielsdos) - Random: . Fix Randomizer::__serialize() w.r.t. INDIRECTs. (nielsdos) diff --git a/ext/phar/zip.c b/ext/phar/zip.c index 47a518f53ce..c188d6513ab 100644 --- a/ext/phar/zip.c +++ b/ext/phar/zip.c @@ -1417,6 +1417,7 @@ fperror: pass.centralfp = php_stream_fopen_tmpfile(); if (!pass.centralfp) { + php_stream_close(pass.filefp); goto fperror; }