aboutsummaryrefslogtreecommitdiff
path: root/nxcomp/src/Log.h
diff options
context:
space:
mode:
authorMihai Moldovan <ionic@ionic.de>2017-12-09 13:16:37 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-09 13:16:37 +0100
commit804ff44523ab726fdb59b80193652465df0482ee (patch)
tree638d62dce7a3e1f4245cb53212e3e422f310be99 /nxcomp/src/Log.h
parent6d7536bd4f5cad9a779c186bd2649b34ec71b367 (diff)
parent4dbee3a3f13657577f283bca22b281d7273c19e5 (diff)
downloadnx-libs-804ff44523ab726fdb59b80193652465df0482ee.tar.gz
nx-libs-804ff44523ab726fdb59b80193652465df0482ee.tar.bz2
nx-libs-804ff44523ab726fdb59b80193652465df0482ee.zip
Merge branch 'uli42-pr/fix_memleaks' into 3.6.x
Attributes GH PR #575: https://github.com/ArcticaProject/nx-libs/pull/575 Fixes: ArcticaProject/nx-libs#569 Fixes: ArcticaProject/nx-libs#573
Diffstat (limited to 'nxcomp/src/Log.h')
-rw-r--r--nxcomp/src/Log.h16
1 files changed, 15 insertions, 1 deletions
diff --git a/nxcomp/src/Log.h b/nxcomp/src/Log.h
index aed929b31..3e355a951 100644
--- a/nxcomp/src/Log.h
+++ b/nxcomp/src/Log.h
@@ -168,7 +168,13 @@ class NXLog
delete pdt->thread_name;
while (!pdt->buffer.empty()) {
+ /*
+ * get the stringstream object created in new_stack_entry()
+ * from the stack and delete it after pop()
+ */
+ std::stringstream* tmp = pdt->buffer.top();
(void) pdt->buffer.pop ();
+ delete tmp;
}
delete pdt;
@@ -240,7 +246,12 @@ class NXLog
pthread_sigmask(SIG_BLOCK, &tmp_signal_mask, &orig_signal_mask);
if (!pdt->buffer.empty ()) {
- const std::string str = pdt->buffer.top()->str();
+ /*
+ * get the stringstream object created in new_stack_entry()
+ * from the stack and delete it after pop()
+ */
+ std::stringstream *tmp = pdt->buffer.top();
+ const std::string str = tmp->str();
if (!str.empty())
{
@@ -251,6 +262,9 @@ class NXLog
/* Remove from stack. */
pdt->buffer.pop();
+
+ /* free memory */
+ delete tmp;
}
/* Restore old signal mask. */