]> granicus.if.org Git - icinga2/commitdiff
Fix memory leak in Stream::Close
authorGunnar Beutner <gunnar@beutner.name>
Wed, 3 Feb 2016 11:56:54 +0000 (12:56 +0100)
committerGunnar Beutner <gunnar@beutner.name>
Wed, 3 Feb 2016 12:02:49 +0000 (13:02 +0100)
refs #10655

lib/base/stream.cpp

index 796a2c83ddec440f61d6ff6bf8411b65c245cc12..240f9cb7bff54b1cb1ff2ffb0298c5bb7b3127e5 100644 (file)
@@ -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)