postgresql plugin: Don't access realloc'ed memory.
authorSebastian Harl <sh@tokkee.org>
Wed, 23 Jan 2013 08:26:48 +0000 (09:26 +0100)
committerSebastian Harl <sh@tokkee.org>
Wed, 23 Jan 2013 08:26:48 +0000 (09:26 +0100)
commit7bbba254348a7fa98c4337455a3e0eae88ce0e86
tree50cde8126c381d076dfddbffbc46ed54fc5af461
parent099531004e4b98e1e1d8a023975799708473b011
postgresql plugin: Don't access realloc'ed memory.

D'oh! This is the most stupidest bug: all database connection objects are
stored in a plugin-global array and a pointer to each object was passed around
to the worker functions. This array used to be an array of objects (rather
than pointers) and was realloc'ed every time a new connection was added. Now,
the realloc caused the old pointer to not be valid any more, thus, any but the
last database connection were later accessing memory out of range. This caused
the plugin to segfault if more than one database connection was used.

Thanks to Greg Swift for reporting this!
Fixes Github issue #238.
src/postgresql.c