aboutsummaryrefslogtreecommitdiff
path: root/nxcomp
diff options
context:
space:
mode:
authorUlrich Sibiller <uli42@gmx.de>2017-11-28 21:58:07 +0100
committerMihai Moldovan <ionic@ionic.de>2017-12-09 13:15:35 +0100
commit2814677a7e2b259669708c89ed55b55dc1c46f9c (patch)
tree2124a92b785613dda904bf7ee4a6aa27a81ba856 /nxcomp
parent1c09eab703de18430241a11abec0526512d851b9 (diff)
downloadnx-libs-2814677a7e2b259669708c89ed55b55dc1c46f9c.tar.gz
nx-libs-2814677a7e2b259669708c89ed55b55dc1c46f9c.tar.bz2
nx-libs-2814677a7e2b259669708c89ed55b55dc1c46f9c.zip
Loop.cpp: fix more memory leaks
The thread specific stringstream objects on the stack need to be deleted, not just pop()ed. Fixes ArcticaProject/nx-libs#573 (partially)
Diffstat (limited to 'nxcomp')
-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. */