Commit 2814677a authored by Ulrich Sibiller's avatar Ulrich Sibiller Committed by Mihai Moldovan

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)
parent 1c09eab7
...@@ -168,7 +168,13 @@ class NXLog ...@@ -168,7 +168,13 @@ class NXLog
delete pdt->thread_name; delete pdt->thread_name;
while (!pdt->buffer.empty()) { 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 (); (void) pdt->buffer.pop ();
delete tmp;
} }
delete pdt; delete pdt;
...@@ -240,7 +246,12 @@ class NXLog ...@@ -240,7 +246,12 @@ class NXLog
pthread_sigmask(SIG_BLOCK, &tmp_signal_mask, &orig_signal_mask); pthread_sigmask(SIG_BLOCK, &tmp_signal_mask, &orig_signal_mask);
if (!pdt->buffer.empty ()) { 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()) if (!str.empty())
{ {
...@@ -251,6 +262,9 @@ class NXLog ...@@ -251,6 +262,9 @@ class NXLog
/* Remove from stack. */ /* Remove from stack. */
pdt->buffer.pop(); pdt->buffer.pop();
/* free memory */
delete tmp;
} }
/* Restore old signal mask. */ /* Restore old signal mask. */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment