Don't try to translate NULL in GetConfigOptionByNum().
authorAndres Freund <andres@anarazel.de>
Wed, 23 Mar 2022 20:05:59 +0000 (13:05 -0700)
committerAndres Freund <andres@anarazel.de>
Wed, 23 Mar 2022 20:05:59 +0000 (13:05 -0700)
Noticed via -fsanitize=undefined. Introduced when a few columns in
GetConfigOptionByNum() / pg_settings started to be translated in 72be8c29a /
PG 12.

Backpatch to all affected branches, for the same reasons as 46ab07ffda9.

Discussion: https://postgr.es/m/20220323173537.ll7klrglnp4gn2um@alap3.anarazel.de
Backpatch: 12-

src/backend/utils/misc/guc.c

index 932aefc777d7420105dcf4a48bc5e3da50c9faec..f70f7f5c01e0a5a96a012b80aa955a8ecd65ef46 100644 (file)
@@ -9797,7 +9797,7 @@ GetConfigOptionByNum(int varnum, const char **values, bool *noshow)
    values[4] = _(conf->short_desc);
 
    /* extra_desc */
-   values[5] = _(conf->long_desc);
+   values[5] = conf->long_desc != NULL ? _(conf->long_desc) : NULL;
 
    /* context */
    values[6] = GucContext_Names[conf->context];