From 5f2350a043db08ab0ea48d22f51acfa5d9b374d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C3=81lvaro=20Herrera?= Date: Tue, 24 Mar 2026 16:45:39 +0100 Subject: [PATCH] Fix dereference in a couple of GUC check hooks check_backtrace_functions() and check_archive_directory() were doing an empty-string check this way: *newval[0] == '\0' which, because of operator precedence, is interpreted as *(newval[0]) instead of (*newval)[0] -- but these variables are pointers to C-strings and we want to check the first character therein, rather than check the first pointer of the array, so that interpretation is wrong. This would be wrong for any index element other than 0, as evidenced by every other dereference of the same variable in check_backtrace_functions, which use parentheses. Add parentheses to make the intended dereference explicit. This is just cosmetic at this stage, so no backpatch, although it's been "wrong" for a long time. Author: Zhang Hu Reviewed-by: Junwang Zhao Reviewed-by: Chao Li Discussion: https://postgr.es/m/CAB5m2QssN6UO+ckr6ZCcV0A71mKUB6WdiTw1nHo43v4DTW1Dfg@mail.gmail.com --- contrib/basic_archive/basic_archive.c | 2 +- src/backend/utils/error/elog.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/contrib/basic_archive/basic_archive.c b/contrib/basic_archive/basic_archive.c index 8c7e9be624f..914a0b56d16 100644 --- a/contrib/basic_archive/basic_archive.c +++ b/contrib/basic_archive/basic_archive.c @@ -100,7 +100,7 @@ check_archive_directory(char **newval, void **extra, GucSource source) * Our check_configured callback also checks for this and prevents * archiving from proceeding if it is still empty. */ - if (*newval == NULL || *newval[0] == '\0') + if (*newval == NULL || (*newval)[0] == '\0') return true; /* diff --git a/src/backend/utils/error/elog.c b/src/backend/utils/error/elog.c index 80b78f25267..314ef85fdb4 100644 --- a/src/backend/utils/error/elog.c +++ b/src/backend/utils/error/elog.c @@ -2627,7 +2627,7 @@ check_backtrace_functions(char **newval, void **extra, GucSource source) return false; } - if (*newval[0] == '\0') + if ((*newval)[0] == '\0') { *extra = NULL; return true;