aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/commit_ts.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-09-24 11:30:51 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-09-24 11:30:51 -0400
commitbfdd02f88b9678dea0e0ba5866ee772f3aa55cba (patch)
treeb8ad73dbc1842989ec124f14ef3450530e808a7d /src/backend/access/transam/commit_ts.c
parent89f2b64da370e7b0737760e3282f096591d6518f (diff)
downloadpostgresql-bfdd02f88b9678dea0e0ba5866ee772f3aa55cba.tar.gz
postgresql-bfdd02f88b9678dea0e0ba5866ee772f3aa55cba.zip
Fix over-allocation of space for array_out()'s result string.
array_out overestimated the space needed for its output, possibly by a very substantial amount if the array is multi-dimensional, because of wrong order of operations in the loop that counts the number of curly-brace pairs needed. While the output string is normally short-lived, this could still cause problems in extreme cases. An additional minor error was that it counted one more delimiter than is actually needed. Repair those errors, add an Assert that the space is now correctly calculated, and make some minor improvements in the comments. I also failed to resist the temptation to get rid of an integer modulus operation per array element; a simple comparison is sufficient. This bug dates clear back to Berkeley days, so back-patch to all supported versions. Keiichi Hirobe, minor additional work by me Discussion: https://postgr.es/m/CAH=EFxE9W0tRvQkixR2XJRRCToUYUEDkJZk6tnADXugPBRdcdg@mail.gmail.com
Diffstat (limited to 'src/backend/access/transam/commit_ts.c')
0 files changed, 0 insertions, 0 deletions