aboutsummaryrefslogtreecommitdiffstats
path: root/CommonLibs/LinkedLists.cpp
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2018-12-03 12:35:21 +0100
committerHarald Welte <laforge@gnumonks.org>2018-12-03 12:59:12 +0000
commit41c68aa41cd21a0298eeea1dfbf935e1e4106d13 (patch)
tree5300c816ea855d5c9fa039e3d40fe6deb4f9332e /CommonLibs/LinkedLists.cpp
parent39e0bbaccaa8b0079d7ff32b0b1f1a289d23eb33 (diff)
PointerFIFO: Fix memleak of ListNode
Found by ASan. when PointerFIFO::release() is called, alloicated node being released is actually stored into an internal list for later-reuse without having to access memory allocator. However, nodes from this list are never freed. Change-Id: I40e5e28603cde67005d9d92772967b05465ea2b8
Diffstat (limited to 'CommonLibs/LinkedLists.cpp')
-rw-r--r--CommonLibs/LinkedLists.cpp19
1 files changed, 19 insertions, 0 deletions
diff --git a/CommonLibs/LinkedLists.cpp b/CommonLibs/LinkedLists.cpp
index 35a8541..b73a579 100644
--- a/CommonLibs/LinkedLists.cpp
+++ b/CommonLibs/LinkedLists.cpp
@@ -29,6 +29,25 @@
#include "LinkedLists.h"
+PointerFIFO::~PointerFIFO()
+{
+ ListNode *node, *next;
+
+ node = mHead;
+ while (node != NULL) {
+ next = node->next();
+ delete node;
+ node = next;
+ }
+
+ node = mFreeList;
+ while (node != NULL) {
+ next = node->next();
+ delete node;
+ node = next;
+ }
+}
+
void PointerFIFO::push_front(void* val) // by pat
{
// Pat added this routine for completeness, but never used or tested.