From: Tom Lane Date: Thu, 11 Dec 2014 00:06:27 +0000 (-0500) Subject: Fix minor thinko in convertToJsonb(). X-Git-Tag: REL9_5_ALPHA1~1082 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=24688f4e5a7d5fadde0e43a5b123432d81577d82;p=thirdparty%2Fpostgresql.git Fix minor thinko in convertToJsonb(). The amount of space to reserve for the value's varlena header is VARHDRSZ, not sizeof(VARHDRSZ). The latter coding accidentally failed to fail because of the way the VARHDRSZ macro is currently defined; but if we ever change it to return size_t (as one might reasonably expect it to do), convertToJsonb() would have failed. Spotted by Mark Dilger. --- diff --git a/src/backend/utils/adt/jsonb_util.c b/src/backend/utils/adt/jsonb_util.c index 2ff85396d01..c62941baa7b 100644 --- a/src/backend/utils/adt/jsonb_util.c +++ b/src/backend/utils/adt/jsonb_util.c @@ -1377,7 +1377,7 @@ convertToJsonb(JsonbValue *val) initStringInfo(&buffer); /* Make room for the varlena header */ - reserveFromBuffer(&buffer, sizeof(VARHDRSZ)); + reserveFromBuffer(&buffer, VARHDRSZ); convertJsonbValue(&buffer, &jentry, val, 0);