postgres.git / summary / log / commit / refs
commit 661237056b3ad92af40bc674459152d5ea0a58bb
Author: Álvaro Herrera <alvherre@kurilemu.de>
Date: Tue Feb 17 15:38:24 2026 +0000
Fix memory leak in new GUC check_hook
Commit 38e0190ced71 forgot to pfree() an allocation (freed in other
places of the same function) in only one of several spots in
check_log_min_messages(). Per Coverity. Add that.
While at it, avoid open-coding guc_strdup(). The new coding does a
strlen() that wasn't there before, but I doubt it's measurable.
src/backend/utils/error/elog.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c
index 59315e94e3e..cb1c9d85ffe 100644
--- a/src/backend/utils/error/elog.c
+++ b/src/backend/utils/error/elog.c
@@ -2363,11 +2363,12 @@ lmm_fail:
appendStringInfo(&buf, ", %s", elem);
}
- result = (char *) guc_malloc(LOG, buf.len + 1);
+ result = guc_strdup(LOG, buf.data);
if (!result)
+ {
+ pfree(buf.data);
return false;
- memcpy(result, buf.data, buf.len);
- result[buf.len] = '\0';
+ }
guc_free(*newval);
*newval = result;
[parent: a92b809f9da1]