Qt: fix memory leaks in VoIP calls window
authorPascal Quantin <pascal.quantin@gmail.com>
Sun, 25 Oct 2015 18:24:06 +0000 (19:24 +0100)
committerPascal Quantin <pascal.quantin@gmail.com>
Mon, 26 Oct 2015 11:06:51 +0000 (11:06 +0000)
- Add free of h245_labels to voip_calls_remove_all_tap_listeners() so that memory is not leaked with Qt GUI
- Call voip_calls_reset_all_taps() from VoipCallsDialog destructor so as to free allocated memory

Change-Id: I46945b5d475d8c1267819021a4ed2782c531a0c6
Reviewed-on: https://code.wireshark.org/review/11268
Petri-Dish: Pascal Quantin <pascal.quantin@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Pascal Quantin <pascal.quantin@gmail.com>
ui/qt/voip_calls_dialog.cpp
ui/voip_calls.c

index 38b919c94a4ddd565d92df6d15e3a0d584f7779b..486e3a604ce76c0d2441f1edf8f9ff4333313be2 100644 (file)
@@ -214,8 +214,10 @@ VoipCallsDialog::~VoipCallsDialog()
 {
     delete ui;
 
+    voip_calls_reset_all_taps(&tapinfo_);
     voip_calls_remove_all_tap_listeners(&tapinfo_);
     sequence_analysis_info_free(tapinfo_.graph_analysis);
+    g_queue_free(tapinfo_.callsinfos);
 }
 
 void VoipCallsDialog::captureFileClosing()
index 17643d796f72c740af0dc0b74e1a6caea2c070b9..fff48ef5c64146d7f8b5a1129dcfab4f333b71fc 100644 (file)
@@ -290,13 +290,7 @@ voip_calls_reset_all_taps(voip_calls_tapinfo_t *tapinfo)
     g_list_free(tapinfo->rtp_stream_list);
     tapinfo->rtp_stream_list = NULL;
 
-    if (!tapinfo->h245_labels) {
-        /*
-         * XXX - given that we set this in fff, will this ever be
-         * the case?
-         */
-        tapinfo->h245_labels = g_new0(h245_labels_t, 1);
-    } else {
+    if (tapinfo->h245_labels) {
         memset(tapinfo->h245_labels, 0, sizeof(h245_labels_t));
     }
 
@@ -2222,7 +2216,9 @@ h245dg_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
 {
     GString *error_string;
 
-    tap_id_base->h245_labels = g_new0(h245_labels_t, 1);
+    if (!tap_id_base->h245_labels) {
+        tap_id_base->h245_labels = g_new0(h245_labels_t, 1);
+    }
 
     error_string = register_tap_listener("h245dg", tap_base_to_id(tap_id_base, tap_id_offset_h245dg_), NULL,
             0,
@@ -2242,6 +2238,10 @@ h245dg_calls_init_tap(voip_calls_tapinfo_t *tap_id_base)
 void
 remove_tap_listener_h245dg_calls(voip_calls_tapinfo_t *tap_id_base)
 {
+    if (tap_id_base->h245_labels) {
+        g_free(tap_id_base->h245_labels);
+        tap_id_base->h245_labels = NULL;
+    }
     remove_tap_listener(tap_base_to_id(tap_id_base, tap_id_offset_h245dg_));
 }