From ca1044d00a3a2b23e29c8b96dfb1c56defeca9dc Mon Sep 17 00:00:00 2001 From: Julien Rouhaud Date: Mon, 31 Aug 2015 17:19:33 +0200 Subject: [PATCH] Fix hypopg_reset() function. Previously, the entries wasn't remove in hypo_entry_remove() due to forgotten lfirst() calll, leading to memory leak in the backend's TopMemoryContext. The loop was also wrong, also fixed. --- hypopg.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/hypopg.c b/hypopg.c index 8ca337c..a352f2f 100644 --- a/hypopg.c +++ b/hypopg.c @@ -423,9 +423,13 @@ hypo_entry_reset(void) { ListCell *lc; - foreach(lc, entries) + /* + * The cell is removed in hypo_entry_remove(), so we can't iterate using + * standard foreach / lnext macros. + */ + while ((lc = list_head(entries)) != NULL) { - hypoEntry *entry = (hypoEntry *) lc; + hypoEntry *entry = (hypoEntry *) lfirst(lc); hypo_entry_remove(entry->oid); }