]> granicus.if.org Git - postgresql/commit
Fix broken allocation logic in recently-rewritten jsonb_util.c.
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 May 2014 22:24:17 +0000 (18:24 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 9 May 2014 22:24:17 +0000 (18:24 -0400)
commit3d8c2b496fc1fed2b8ff8a403d3a17329325466e
tree920fe41eaaf270a36d7af0af7bf89e9d65176544
parent0b92a77c17ebe8bec08e250e1a929b07efef1008
Fix broken allocation logic in recently-rewritten jsonb_util.c.

reserveFromBuffer() failed to consider the possibility that it needs to
more-than-double the current buffer size.  Beyond that, it seems likely
that we'd someday need to worry about integer overflow of the buffer
length variable.  Rather than reinvent the logic that's already been
debugged in stringinfo.c, let's go back to using that logic.  We can
still have the same targeted API, but we'll rely on stringinfo.c to
manage reallocation.

Per report from Alexander Korotkov.
src/backend/utils/adt/jsonb_util.c