summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathan Bossart2025-04-06 20:11:41 +0000
committerNathan Bossart2025-04-06 20:11:41 +0000
commitde48056ec7d237e6a48dce907804ac26c87311ec (patch)
tree8f4d22578b8b783052dd241114be02571118841a /src
parent57dec20fd4691900fbe118699d32640fc538dc20 (diff)
pg_upgrade: Fix memory leak in check_for_unicode_update().
This function was initializing the "task" variable before a couple of early returns. To fix, postpone the initialization until just before it's needed. Per Coverity. Discussion: https://postgr.es/m/Z_KMsUH2-FEbiNjC%40nathan
Diffstat (limited to 'src')
-rw-r--r--src/bin/pg_upgrade/check.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/bin/pg_upgrade/check.c b/src/bin/pg_upgrade/check.c
index 8f946c4e3d6..18c2d652bb6 100644
--- a/src/bin/pg_upgrade/check.c
+++ b/src/bin/pg_upgrade/check.c
@@ -1825,7 +1825,7 @@ static void
check_for_unicode_update(ClusterInfo *cluster)
{
UpgradeTaskReport report;
- UpgradeTask *task = upgrade_task_create();
+ UpgradeTask *task;
const char *query;
/*
@@ -1920,6 +1920,7 @@ check_for_unicode_update(ClusterInfo *cluster)
" d.datname = current_database() AND "
" d.encoding = pg_char_to_encoding('UTF8');";
+ task = upgrade_task_create();
upgrade_task_add_step(task, query,
process_unicode_update,
true, &report);