From c2f722656173ab799a66268ed0268d4061981585 Mon Sep 17 00:00:00 2001 From: "Chao Li (Evan)" Date: Tue, 1 Dec 2026 14:58:17 +0800 Subject: [PATCH v1] pg_upgrade: fix use-after-close in cleanup_output_dirs() cleanup_output_dirs() closes the internal log file before checking the output directory. If that check fails, logging the warning attempts to write to the closed stream. Set log_opts.internal to NULL after fclose() so the warning is written only to stdout. Author: Chao Li --- src/bin/pg_upgrade/util.c | 1 + 1 file changed, 1 insertion(+) diff --git a/src/bin/pg_upgrade/util.c b/src/bin/pg_upgrade/util.c index abdb35764de..67213351200 100644 --- a/src/bin/pg_upgrade/util.c +++ b/src/bin/pg_upgrade/util.c @@ -64,6 +64,7 @@ void cleanup_output_dirs(void) { fclose(log_opts.internal); + log_opts.internal = NULL; /* Remove dump and log files? */ if (log_opts.retain) -- 2.50.1 (Apple Git-155)