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 <kongbaik228@gmail.com>
Reviewed-by: Junwang Zhao <zhjwpku@gmail.com>
Reviewed-by: Chao Li <lic@highgo.com>
Discussion: https://postgr.es/m/CAB5m2QssN6UO+ckr6ZCcV0A71mKUB6WdiTw1nHo43v4DTW1Dfg@mail.gmail.com
This commit is contained in:
Álvaro Herrera 2026-03-24 16:45:39 +01:00
parent c7b9f16113
commit 5f2350a043
No known key found for this signature in database
GPG key ID: 1C20ACB9D5C564AE
2 changed files with 2 additions and 2 deletions

View file

@ -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;
/*

View file

@ -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;