From fe196d47377af70aeb42d2597a264af6301f10e8 Mon Sep 17 00:00:00 2001 From: Niels Dossche <7771979+nielsdos@users.noreply.github.com> Date: Sun, 7 Jul 2024 21:53:58 +0200 Subject: [PATCH] Fix memory leak in tidy_repair_file() When dealing with a file, we must free the contents if the function fails. While here, also fix the error message because previously it sounded like the filename was too long while in fact the file itself is too large. --- ext/tidy/tests/parsing_file_too_large.phpt | 7 +++++++ ext/tidy/tidy.c | 7 ++++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/ext/tidy/tests/parsing_file_too_large.phpt b/ext/tidy/tests/parsing_file_too_large.phpt index 46196c0a5fdce..a0118ba9ebdce 100644 --- a/ext/tidy/tests/parsing_file_too_large.phpt +++ b/ext/tidy/tests/parsing_file_too_large.phpt @@ -47,6 +47,12 @@ try { } catch (\Throwable $e) { echo $e::class, ': ', $e->getMessage(), PHP_EOL; } + +try { + tidy_repair_file($path); +} catch (\Throwable $e) { + echo $e::class, ': ', $e->getMessage(), PHP_EOL; +} ?> --CLEAN--