Skip to content

Commit 7186c43

Browse files
committed
Avoid memory leak on deletion from uint64 list
1 parent 8c5bc59 commit 7186c43

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

hash.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,11 @@ lappend_uint64(List *list, uint64 datum)
131131
return list;
132132
}
133133

134+
/*
135+
* Remove element from a list and free the memory which was allocated to it.
136+
* Looks unconventional, but we unconventionally allocate memory on append, so
137+
* it maybe ok.
138+
*/
134139
List *
135140
ldelete_uint64(List *list, uint64 datum)
136141
{
@@ -140,6 +145,7 @@ ldelete_uint64(List *list, uint64 datum)
140145
{
141146
if (*((uint64 *)lfirst(cell)) == datum)
142147
{
148+
pfree(lfirst(cell));
143149
list = list_delete_ptr(list, lfirst(cell));
144150
return list;
145151
}

0 commit comments

Comments
 (0)