From caf3380e73558c7f67bb5deb0d1c88edcaad0900 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Wed, 3 Feb 2016 12:56:54 +0100 Subject: [PATCH] Fix memory leak in Stream::Close refs #10655 --- lib/base/stream.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lib/base/stream.cpp b/lib/base/stream.cpp index 796a2c83d..240f9cb7b 100644 --- a/lib/base/stream.cpp +++ b/lib/base/stream.cpp @@ -76,9 +76,16 @@ bool Stream::WaitForData(int timeout) return IsDataAvailable() || IsEof(); } +static void StreamDummyCallback(void) +{ } + void Stream::Close(void) { OnDataAvailable.disconnect_all_slots(); + + /* Force signals2 to remove the slots, see https://stackoverflow.com/questions/2049291/force-deletion-of-slot-in-boostsignals2 + * for details. */ + OnDataAvailable.connect(boost::bind(&StreamDummyCallback)); } StreamReadStatus Stream::ReadLine(String *line, StreamReadContext& context, bool may_wait) -- 2.40.0