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 want to reserve sizeof(int32), not sizeof(int64) in convertToJsonb. Perhaps the code really meant to say: reserveFromBuffer(&buffer, VARHDRSZ) mark -- Sent via pgsql-hackers mailing list (pgsql-hackers@postgresql.org) To make changes to your subscription: http://www.postgresql.org/mailpref/pgsql-hackers