Change in osmo-trx[master]: PointerFIFO: Fix memleak of ListNode

This is merely a historical archive of years 2008-2021, before the migration to mailman3.

A maintained and still updated list archive can be found at https://lists.osmocom.org/hyperkitty/list/gerrit-log@lists.osmocom.org/.

Pau Espin Pedrol gerrit-no-reply at lists.osmocom.org
Mon Dec 3 13:04:16 UTC 2018


Pau Espin Pedrol has submitted this change and it was merged. ( https://gerrit.osmocom.org/12078 )

Change subject: PointerFIFO: Fix memleak of ListNode
......................................................................

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
---
M CommonLibs/LinkedLists.cpp
M CommonLibs/LinkedLists.h
2 files changed, 20 insertions(+), 0 deletions(-)

Approvals:
  Harald Welte: Looks good to me, approved
  Jenkins Builder: Verified



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.
diff --git a/CommonLibs/LinkedLists.h b/CommonLibs/LinkedLists.h
index 31fb9c5..136d13d 100644
--- a/CommonLibs/LinkedLists.h
+++ b/CommonLibs/LinkedLists.h
@@ -70,6 +70,7 @@
 		:mHead(NULL),mTail(NULL),mFreeList(NULL),
 		mSize(0)
 	{}
+	~PointerFIFO();
 
 	unsigned size() const { return mSize; }
 	unsigned totalSize() const { return 0; }	// Not used in this version.

-- 
To view, visit https://gerrit.osmocom.org/12078
To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings

Gerrit-Project: osmo-trx
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: I40e5e28603cde67005d9d92772967b05465ea2b8
Gerrit-Change-Number: 12078
Gerrit-PatchSet: 2
Gerrit-Owner: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-Reviewer: Harald Welte <laforge at gnumonks.org>
Gerrit-Reviewer: Jenkins Builder (1000002)
Gerrit-Reviewer: Pau Espin Pedrol <pespin at sysmocom.de>
Gerrit-CC: Vadim Yanitskiy <axilirator at gmail.com>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osmocom.org/pipermail/gerrit-log/attachments/20181203/89f83c5b/attachment.htm>


More information about the gerrit-log mailing list