Fix small memory leaks in GUC checks
authorDaniel Gustafsson <[email protected]>
Mon, 9 Dec 2024 19:58:23 +0000 (20:58 +0100)
committerDaniel Gustafsson <[email protected]>
Mon, 9 Dec 2024 19:58:23 +0000 (20:58 +0100)
Follow-up commit to a9d58bfe8a3a.  Backpatch down to v16 where
this was added in order to keep the code consistent for future
backpatches.

Author: Tofig Aliev <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Discussion: https://postgr.es/m/bba4313fdde9db46db279f96f3b748b1@postgrespro.ru
Backpatch-through: 16

src/backend/commands/variable.c

index a81d236c6a9554311bc15ccc74f91d1885941be8..8ea1fd9a63d274eec86c0a948bb348f6492bf82e 100644 (file)
@@ -1082,6 +1082,8 @@ check_application_name(char **newval, void **extra, GucSource source)
        return false;
    }
 
+   guc_free(*newval);
+
    pfree(clean);
    *newval = ret;
    return true;
@@ -1118,6 +1120,8 @@ check_cluster_name(char **newval, void **extra, GucSource source)
        return false;
    }
 
+   guc_free(*newval);
+
    pfree(clean);
    *newval = ret;
    return true;