]> granicus.if.org Git - postgresql/commit
Fix potential memory clobber in tsvector_concat().
authorTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Aug 2011 20:51:39 +0000 (16:51 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Fri, 26 Aug 2011 20:51:39 +0000 (16:51 -0400)
commit93809ad5eb8f0dbd704b2f713f707d8cf684fd57
treee37a1187c1960cd8547304fa1151209c7d9a646d
parent39a713ea059a8ad3d07e3ea4d2c9b5da1fe3fa25
Fix potential memory clobber in tsvector_concat().

tsvector_concat() allocated its result workspace using the "conservative"
estimate of the sum of the two input tsvectors' sizes.  Unfortunately that
wasn't so conservative as all that, because it supposed that the number of
pad bytes required could not grow.  Which it can, as per test case from
Jesper Krogh, if there's a mix of lexemes with positions and lexemes
without them in the input data.  The fix is to assume that we might add
a not-previously-present pad byte for each and every lexeme in the two
inputs; which really is conservative, but it doesn't seem worthwhile to
try to be more precise.

This is an aboriginal bug in tsvector_concat, so back-patch to all
versions containing it.
src/backend/utils/adt/tsvector_op.c