Make replace(), split_part(), and string_to_array() behave somewhat sanely
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Jul 2007 20:34:54 +0000 (20:34 +0000)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 19 Jul 2007 20:34:54 +0000 (20:34 +0000)
commit03899a2e0aebbbc2f76334514e98c1262c351c51
tree7e9f107bb2c88e940bb144e77ca8db82f2490c29
parent1ea3eccbce8336d84739138a1f74aa0d90bcc98b
Make replace(), split_part(), and string_to_array() behave somewhat sanely
when handed an invalidly-encoded pattern.  The previous coding could get
into an infinite loop if pg_mb2wchar_with_len() returned a zero-length
string after we'd tested for nonempty pattern; which is exactly what it
will do if the string consists only of an incomplete multibyte character.
This led to either an out-of-memory error or a backend crash depending
on platform.  Per report from Wiktor Wodecki.
src/backend/utils/adt/varlena.c