aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2018-03-25 23:24:59 +0200
committerAnders Broman <a.broman58@gmail.com>2018-03-27 04:51:00 +0000
commit802223829e9899638557c4cf13a5a643d96a0385 (patch)
tree2899e282a67eebf55522b00870ac52d5b653de78
parent3b042a717258e331f670bfc322e59d4b191a93db (diff)
tap: fix remaining potential memleaks with register_tap_listener
Additionally, add an attribute to the tap function to prevent future callers from leaking this memory. Change-Id: Ief6af2bbc74d19153628f09d7b273e85cb2284ab Reviewed-on: https://code.wireshark.org/review/26642 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman <a.broman58@gmail.com>
-rw-r--r--epan/tap.h2
-rw-r--r--ui/gtk/flow_graph.c10
-rw-r--r--ui/qt/rtp_player_dialog.cpp10
-rw-r--r--ui/qt/sequence_dialog.cpp8
-rw-r--r--ui/qt/wireless_timeline.cpp10
5 files changed, 34 insertions, 6 deletions
diff --git a/epan/tap.h b/epan/tap.h
index 7b13c2fc15..dfd274423e 100644
--- a/epan/tap.h
+++ b/epan/tap.h
@@ -208,7 +208,7 @@ WS_DLL_PUBLIC void draw_tap_listeners(gboolean draw_all);
WS_DLL_PUBLIC GString *register_tap_listener(const char *tapname, void *tapdata,
const char *fstring, guint flags, tap_reset_cb tap_reset,
- tap_packet_cb tap_packet, tap_draw_cb tap_draw);
+ tap_packet_cb tap_packet, tap_draw_cb tap_draw) G_GNUC_WARN_UNUSED_RESULT;
/** This function sets a new dfilter to a tap listener */
WS_DLL_PUBLIC GString *set_tap_dfilter(void *tapdata, const char *fstring);
diff --git a/ui/gtk/flow_graph.c b/ui/gtk/flow_graph.c
index 0b79053a03..011ea890e9 100644
--- a/ui/gtk/flow_graph.c
+++ b/ui/gtk/flow_graph.c
@@ -28,6 +28,7 @@
#include <epan/packet.h>
#include <epan/stat_tap_ui.h>
+#include <wsutil/report_message.h>
#include "ui/gtk/graph_analysis.h"
#include "ui/gtk/dlg_utils.h"
@@ -159,8 +160,15 @@ flow_graph_on_ok(GtkButton *button _U_, gpointer user_data)
if (analysis != NULL)
{
- register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), graph_analysis, display_filter, sequence_analysis_get_tap_flags(analysis),
+ GString *error_string;
+
+ error_string = register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), graph_analysis, display_filter, sequence_analysis_get_tap_flags(analysis),
NULL, sequence_analysis_get_packet_func(analysis), NULL);
+ if (error_string) {
+ report_failure("Flow graph - tap registration failed: %s", error_string->str);
+ g_string_free(error_string, TRUE);
+ return;
+ }
cf_retap_packets(&cfile);
remove_tap_listener(graph_analysis);
diff --git a/ui/qt/rtp_player_dialog.cpp b/ui/qt/rtp_player_dialog.cpp
index b42cb55231..0e53a66c94 100644
--- a/ui/qt/rtp_player_dialog.cpp
+++ b/ui/qt/rtp_player_dialog.cpp
@@ -13,6 +13,7 @@
#include <epan/dissectors/packet-rtp.h>
+#include <wsutil/report_message.h>
#include <wsutil/utf8_entities.h>
#include <ui/qt/utils/color_utils.h>
@@ -209,7 +210,14 @@ void RtpPlayerDialog::reject()
void RtpPlayerDialog::retapPackets()
{
- register_tap_listener("rtp", this, NULL, 0, NULL, tapPacket, NULL);
+ GString *error_string;
+
+ error_string = register_tap_listener("rtp", this, NULL, 0, NULL, tapPacket, NULL);
+ if (error_string) {
+ report_failure("RTP Player - tap registration failed: %s", error_string->str);
+ g_string_free(error_string, TRUE);
+ return;
+ }
cap_file_.retapPackets();
remove_tap_listener(this);
diff --git a/ui/qt/sequence_dialog.cpp b/ui/qt/sequence_dialog.cpp
index be255e57e3..cca0f8656e 100644
--- a/ui/qt/sequence_dialog.cpp
+++ b/ui/qt/sequence_dialog.cpp
@@ -16,6 +16,7 @@
#include "wsutil/nstime.h"
#include "wsutil/utf8_entities.h"
#include "wsutil/file_util.h"
+#include <wsutil/report_message.h>
#include <ui/qt/utils/color_utils.h>
#include "progress_frame.h"
@@ -421,12 +422,17 @@ void SequenceDialog::fillDiagram()
register_analysis_t* analysis = sequence_analysis_find_by_name(info_->sainfo()->name);
if (analysis != NULL)
{
+ GString *error_string;
const char *filter = NULL;
if (ui->displayFilterCheckBox->checkState() == Qt::Checked)
filter = cap_file_.capFile()->dfilter;
- register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), info_->sainfo(), filter, sequence_analysis_get_tap_flags(analysis),
+ error_string = register_tap_listener(sequence_analysis_get_tap_listener_name(analysis), info_->sainfo(), filter, sequence_analysis_get_tap_flags(analysis),
NULL, sequence_analysis_get_packet_func(analysis), NULL);
+ if (error_string) {
+ report_failure("Sequence dialog - tap registration failed: %s", error_string->str);
+ g_string_free(error_string, TRUE);
+ }
cf_retap_packets(cap_file_.capFile());
remove_tap_listener(info_->sainfo());
diff --git a/ui/qt/wireless_timeline.cpp b/ui/qt/wireless_timeline.cpp
index d4c30d6132..59d084cdeb 100644
--- a/ui/qt/wireless_timeline.cpp
+++ b/ui/qt/wireless_timeline.cpp
@@ -31,7 +31,8 @@
#include <ui/qt/utils/color_utils.h>
#include <ui/qt/utils/qt_ui_utils.h>
#include "wireshark_application.h"
-#include "wsutil/utf8_entities.h"
+#include <wsutil/report_message.h>
+#include <wsutil/utf8_entities.h>
#ifdef Q_OS_WIN
#include "wsutil/file_util.h"
@@ -298,7 +299,12 @@ void WirelessTimeline::captureFileReadFinished()
void WirelessTimeline::appInitialized()
{
- register_tap_listener("wlan_radio_timeline", this, NULL, TL_REQUIRES_NOTHING, tap_timeline_reset, tap_timeline_packet, NULL/*tap_draw_cb tap_draw*/);
+ GString *error_string;
+ error_string = register_tap_listener("wlan_radio_timeline", this, NULL, TL_REQUIRES_NOTHING, tap_timeline_reset, tap_timeline_packet, NULL/*tap_draw_cb tap_draw*/);
+ if (error_string) {
+ report_failure("Wireless Timeline - tap registration failed: %s", error_string->str);
+ g_string_free(error_string, TRUE);
+ }
}
void WirelessTimeline::resizeEvent(QResizeEvent*)