From c570e74384a63b88d38d7697be435dd8de130ac8 Mon Sep 17 00:00:00 2001 From: Mauro Sardara Date: Thu, 31 Oct 2019 15:01:29 +0000 Subject: [HICN-371] Solve memory leaks in libtransport. Signed-off-by: Mauro Sardara Change-Id: I654843c3361c7bdb4b160f2441f08e8d91e97384 Signed-off-by: Mauro Sardara --- libtransport/src/hicn/transport/utils/object_pool.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'libtransport/src/hicn/transport/utils/object_pool.h') diff --git a/libtransport/src/hicn/transport/utils/object_pool.h b/libtransport/src/hicn/transport/utils/object_pool.h index e34730e81..e8f837753 100644 --- a/libtransport/src/hicn/transport/utils/object_pool.h +++ b/libtransport/src/hicn/transport/utils/object_pool.h @@ -47,7 +47,12 @@ class ObjectPool { ObjectPool() : destructor_(false) {} - ~ObjectPool() { destructor_ = true; } + ~ObjectPool() { + destructor_ = true; + for (auto &ptr : object_pool_) { + ptr.reset(); + } + } std::pair get() { if (object_pool_.empty()) { @@ -65,6 +70,8 @@ class ObjectPool { if (TRANSPORT_EXPECT_TRUE(!destructor_)) { object_pool_.emplace_back(makePtr(object)); + } else { + delete object; } } -- cgit 1.2.3-korg