On Sat, Nov 19, 2016 at 9:51 AM, Andreas Seltenreich <[email protected]> wrote:
> Michael Paquier writes:
>
>> [2. text/plain; fix-guc-string-eval.patch]
>
> I'm afraid taking care of the length computation is not sufficient.
> ISTM like it'll still try to serialize the NULL pointer later on in
> serialize_variable:
>
> ,----[ guc.c:9108 ]
> | case PGC_STRING:
> | {
> | struct config_string *conf = (struct config_string *) gconf;
> | do_serialize(destptr, maxbytes, "%s", *conf->variable);
> `----
Hm, yes. Using an empty string strikes as being the best match.
--
Michael
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index 3c695c1..95f36b8 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -8959,7 +8959,10 @@ estimate_variable_size(struct config_generic * gconf)
{
struct config_string *conf = (struct
config_string *) gconf;
- valsize = strlen(*conf->variable);
+ if (*conf->variable && **conf->variable)
+ valsize = strlen(*conf->variable);
+ else
+ valsize = 0;
}
break;
@@ -9109,7 +9112,9 @@ serialize_variable(char **destptr, Size *maxbytes,
{
struct config_string *conf = (struct
config_string *) gconf;
- do_serialize(destptr, maxbytes, "%s",
*conf->variable);
+ do_serialize(destptr, maxbytes, "%s",
+ *conf->variable &&
**conf->variable ?
+ *conf->variable : "");
}
break;
--
Sent via pgsql-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-hackers