pgsql: Fix memory leak in Memoize cache key evaluation

Поиск
Список
Период
Сортировка
От David Rowley
Тема pgsql: Fix memory leak in Memoize cache key evaluation
Дата
Msg-id E1pe3PU-004OgD-1a@gemulon.postgresql.org
обсуждение исходный текст
Список pgsql-committers
Fix memory leak in Memoize cache key evaluation

When probing the Memoize cache to check if the current cache key values
exist in the cache, we perform an evaluation of the expressions making up
the cache key before probing the hash table for those values.  This
operation could leak memory as it is possible that the cache key is an
expression which requires allocation of memory, as was the case in bug
17844.

Here we fix this by correctly switching to the per tuple context before
evaluating the cache expressions so that the memory is freed next time the
per tuple context is reset.

Bug: 17844
Reported-by: Alexey Ermakov
Discussion: https://postgr.es/m/17844-d2f6f9e75a622bed@postgresql.org
Backpatch-through: 14, where Memoize was introduced

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/579ee5df14dfcf5213e502bb096121d2249167c2

Modified Files
--------------
src/backend/executor/nodeMemoize.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)


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

Предыдущее
От: Tom Lane
Дата:
Сообщение: pgsql: Avoid copying undefined data in _readA_Const().
Следующее
От: David Rowley
Дата:
Сообщение: pgsql: Fix memory leak in Memoize cache key evaluation