Potential memory leak in contrib/intarray's g_intbig_compress

Поиск
Список
Период
Сортировка
От Matthias van de Meent
Тема Potential memory leak in contrib/intarray's g_intbig_compress
Дата
Msg-id CAEze2Wi86=DxErfvf+SCB2UKmU2amKOF60BKuJOX=w-RojRn0A@mail.gmail.com
обсуждение исходный текст
Ответы Re: Potential memory leak in contrib/intarray's g_intbig_compress  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
Hi,

My collegue Konstantin (cc-ed) noticed that the GiST code of intarray
may leak memory in certain index operations:

> g_intbig_compress(...):
> [...]
>         ArrayType  *in = DatumGetArrayTypeP(entry->key);
> [...]
>         if (in != DatumGetArrayTypeP(entry->key))
>             pfree(in);

DatumGetArrayTypeP will allocate a new, uncompressed copy if the given
Datum is compressed. So in this code, if entry->key is compressed we'd
allocate two decompressed copies, while only we only deallocate the
first of these two. I believe the attached patch fixes the issue.

It looks like this bug has existed since the code was first committed,
so backpatching would go back to 11 if this is an active issue.

Kind regards,

Matthias van de Meent

Вложения

В списке pgsql-hackers по дате отправления:

Предыдущее
От: Peter Eisentraut
Дата:
Сообщение: Re: Better help output for pgbench -I init_steps
Следующее
От: Amit Langote
Дата:
Сообщение: Re: generic plans and "initial" pruning