Re: [HACKERS] thinko in convertToJsonb()

2014-12-10 Thread Tom Lane
Michael Paquier michael.paqu...@gmail.com writes: On Tue, Dec 9, 2014 at 11:11 AM, Mark Dilger m...@port25.com wrote: Perhaps the code really meant to say: reserveFromBuffer(buffer, VARHDRSZ) Good catch! The code is indeed incorrect. Attached is a one-line patch addressing that, I guess

[HACKERS] thinko in convertToJsonb()

2014-12-09 Thread Mark Dilger
The call: reserveFromBuffer(buffer, sizeof(VARHDRSZ)) is assuming that the size of varlena header is the same size as the type used to return that size, which happens to be so, but someone could easily change that macro to: #define VARHDRSZ ((int64) sizeof(int32)) And you'd

Re: [HACKERS] thinko in convertToJsonb()

2014-12-09 Thread Michael Paquier
On Tue, Dec 9, 2014 at 11:11 AM, Mark Dilger m...@port25.com wrote: The call: reserveFromBuffer(buffer, sizeof(VARHDRSZ)) is assuming that the size of varlena header is the same size as the type used to return that size, which happens to be so, but someone could easily change that