qt: move free_stat_tables from SimpleStatisticsDialog::fillTree to ~SimpleStatisticsDialog.

Add a reference count to stat_tap_table_ui to prevent bad deallocations.

Bug: 12437
Change-Id: Ib9b1f929d08a574c306dc755ec416ab94a3fd6d3
Reviewed-on: https://code.wireshark.org/review/15920
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Dario Lombardo 2016-06-15 00:47:44 +02:00 committed by Anders Broman
parent a38db78f7d
commit 4962ea601f
18 changed files with 85 additions and 48 deletions

View File

@ -5449,7 +5449,8 @@ void proto_register_ansi_map(void) {
NULL,
sizeof(stat_fields)/sizeof(stat_tap_table_item), stat_fields,
0, NULL,
NULL
NULL,
0
};
/* Register protocol */

View File

@ -1544,7 +1544,8 @@ void proto_register_camel(void) {
NULL,
sizeof(camel_stat_fields)/sizeof(stat_tap_table_item), camel_stat_fields,
sizeof(camel_stat_params)/sizeof(tap_param), camel_stat_params,
NULL
NULL,
0
};
/* Register protocol */

View File

@ -3120,7 +3120,8 @@ void proto_register_gsm_map(void) {
NULL,
sizeof(gsm_map_stat_fields)/sizeof(stat_tap_table_item), gsm_map_stat_fields,
sizeof(gsm_map_stat_params)/sizeof(tap_param), gsm_map_stat_params,
NULL
NULL,
0
};
/* Register protocol */

View File

@ -862,7 +862,8 @@ void proto_register_h225(void) {
NULL,
sizeof(h225_stat_fields)/sizeof(stat_tap_table_item), h225_stat_fields,
sizeof(h225_stat_params)/sizeof(tap_param), h225_stat_params,
NULL
NULL,
0
};
module_t *h225_module;

View File

@ -12763,7 +12763,8 @@ proto_register_ansi_a(void)
NULL,
sizeof(dtap_stat_fields)/sizeof(stat_tap_table_item), dtap_stat_fields,
0, NULL,
NULL
NULL,
0
};
static stat_tap_table_ui bsmap_stat_table = {
@ -12778,7 +12779,8 @@ proto_register_ansi_a(void)
NULL,
sizeof(bsmap_stat_fields)/sizeof(stat_tap_table_item), bsmap_stat_fields,
0, NULL,
NULL
NULL,
0
};
memset((void *) ett_dtap_msg, -1, sizeof(ett_dtap_msg));

View File

@ -19519,7 +19519,8 @@ void proto_register_ansi_map(void) {
NULL,
sizeof(stat_fields)/sizeof(stat_tap_table_item), stat_fields,
0, NULL,
NULL
NULL,
0
};
/* Register protocol */

View File

@ -8553,7 +8553,8 @@ proto_register_bootp(void)
NULL,
sizeof(bootp_stat_fields)/sizeof(stat_tap_table_item), bootp_stat_fields,
sizeof(bootp_stat_params)/sizeof(tap_param), bootp_stat_params,
NULL
NULL,
0
};
module_t *bootp_module;

View File

@ -10663,7 +10663,8 @@ void proto_register_camel(void) {
NULL,
sizeof(camel_stat_fields)/sizeof(stat_tap_table_item), camel_stat_fields,
sizeof(camel_stat_params)/sizeof(tap_param), camel_stat_params,
NULL
NULL,
0
};
/* Register protocol */

View File

@ -4680,7 +4680,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_mm_stat_table = {
@ -4695,7 +4696,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_rr_stat_table = {
@ -4710,7 +4712,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_cc_stat_table = {
@ -4725,7 +4728,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_gmm_stat_table = {
@ -4740,7 +4744,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_sm_stat_table = {
@ -4755,7 +4760,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_sms_stat_table = {
@ -4770,7 +4776,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_tp_stat_table = {
@ -4785,7 +4792,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_dtap_ss_stat_table = {
@ -4800,7 +4808,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
static stat_tap_table_ui gsm_a_sacch_rr_stat_table = {
@ -4815,7 +4824,8 @@ proto_register_gsm_a_common(void)
NULL,
sizeof(gsm_a_stat_fields)/sizeof(stat_tap_table_item), gsm_a_stat_fields,
sizeof(gsm_a_stat_params)/sizeof(tap_param), gsm_a_stat_params,
NULL
NULL,
0
};
last_offset = NUM_INDIVIDUAL_ELEMS;

View File

@ -31113,7 +31113,8 @@ void proto_register_gsm_map(void) {
NULL,
sizeof(gsm_map_stat_fields)/sizeof(stat_tap_table_item), gsm_map_stat_fields,
sizeof(gsm_map_stat_params)/sizeof(tap_param), gsm_map_stat_params,
NULL
NULL,
0
};
/* Register protocol */
@ -31221,7 +31222,7 @@ void proto_register_gsm_map(void) {
/*--- End of included file: packet-gsm_map-dis-tab.c ---*/
#line 3148 "./asn1/gsm_map/packet-gsm_map-template.c"
#line 3149 "./asn1/gsm_map/packet-gsm_map-template.c"
oid_add_from_string("ericsson-gsm-Map-Ext","1.2.826.0.1249.58.1.0" );
oid_add_from_string("accessTypeNotAllowed-id","1.3.12.2.1107.3.66.1.2");
/*oid_add_from_string("map-ac networkLocUp(1) version3(3)","0.4.0.0.1.0.1.3" );

View File

@ -1565,7 +1565,7 @@ static const per_sequence_t H221NonStandard_sequence[] = {
static int
dissect_h225_H221NonStandard(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 792 "./asn1/h225/h225.cnf"
#line 790 "./asn1/h225/h225.cnf"
t35CountryCode = 0;
t35Extension = 0;
manufacturerCode = 0;
@ -1573,7 +1573,7 @@ dissect_h225_H221NonStandard(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_H221NonStandard, H221NonStandard_sequence);
#line 796 "./asn1/h225/h225.cnf"
#line 794 "./asn1/h225/h225.cnf"
h221NonStandard = ((t35CountryCode * 256) + t35Extension) * 65536 + manufacturerCode;
proto_tree_add_uint(tree, hf_h221Manufacturer, tvb, (offset>>3)-4, 4, h221NonStandard);
@ -1595,7 +1595,7 @@ static const per_choice_t NonStandardIdentifier_choice[] = {
static int
dissect_h225_NonStandardIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 773 "./asn1/h225/h225.cnf"
#line 771 "./asn1/h225/h225.cnf"
gint32 value;
nsiOID = "";
@ -1624,7 +1624,7 @@ dissect_h225_NonStandardIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t
static int
dissect_h225_T_nsp_data(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 807 "./asn1/h225/h225.cnf"
#line 805 "./asn1/h225/h225.cnf"
tvbuff_t *next_tvb = NULL;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
@ -1647,7 +1647,7 @@ static const per_sequence_t NonStandardParameter_sequence[] = {
int
dissect_h225_NonStandardParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 805 "./asn1/h225/h225.cnf"
#line 803 "./asn1/h225/h225.cnf"
nsp_handle = NULL;
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
@ -2046,7 +2046,7 @@ dissect_h225_PartyNumber(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
static int
dissect_h225_TBCD_STRING(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 902 "./asn1/h225/h225.cnf"
#line 900 "./asn1/h225/h225.cnf"
int min_len, max_len;
gboolean has_extension;
@ -2845,13 +2845,13 @@ static const per_sequence_t TunnelledProtocol_sequence[] = {
int
dissect_h225_TunnelledProtocol(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 750 "./asn1/h225/h225.cnf"
#line 748 "./asn1/h225/h225.cnf"
tpOID = "";
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_TunnelledProtocol, TunnelledProtocol_sequence);
#line 752 "./asn1/h225/h225.cnf"
#line 750 "./asn1/h225/h225.cnf"
tp_handle = dissector_get_string_handle(tp_dissector_table, tpOID);
return offset;
@ -3835,7 +3835,7 @@ dissect_h225_CircuitIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac
static int
dissect_h225_T_standard(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 864 "./asn1/h225/h225.cnf"
#line 862 "./asn1/h225/h225.cnf"
guint32 value_int = (guint32)-1;
gef_ctx_t *gefx;
@ -3853,7 +3853,7 @@ dissect_h225_T_standard(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_,
static int
dissect_h225_T_oid(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 873 "./asn1/h225/h225.cnf"
#line 871 "./asn1/h225/h225.cnf"
const gchar *oid_str = NULL;
gef_ctx_t *gefx;
@ -3883,7 +3883,7 @@ static const per_choice_t GenericIdentifier_choice[] = {
int
dissect_h225_GenericIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 850 "./asn1/h225/h225.cnf"
#line 848 "./asn1/h225/h225.cnf"
gef_ctx_t *gefx;
proto_item* ti;
@ -3891,7 +3891,7 @@ dissect_h225_GenericIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac
ett_h225_GenericIdentifier, GenericIdentifier_choice,
NULL);
#line 853 "./asn1/h225/h225.cnf"
#line 851 "./asn1/h225/h225.cnf"
gef_ctx_update_key(gef_ctx_get(actx->private_data));
gefx = gef_ctx_get(actx->private_data);
if (gefx) {
@ -3908,7 +3908,7 @@ dissect_h225_GenericIdentifier(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *ac
static int
dissect_h225_T_raw(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 883 "./asn1/h225/h225.cnf"
#line 881 "./asn1/h225/h225.cnf"
tvbuff_t *value_tvb;
gef_ctx_t *gefx;
proto_item* ti;
@ -4026,7 +4026,7 @@ static const per_sequence_t EnumeratedParameter_sequence[] = {
static int
dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 832 "./asn1/h225/h225.cnf"
#line 830 "./asn1/h225/h225.cnf"
gef_ctx_t *parent_gefx;
parent_gefx = gef_ctx_get(actx->private_data);
@ -4035,7 +4035,7 @@ dissect_h225_EnumeratedParameter(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_EnumeratedParameter, EnumeratedParameter_sequence);
#line 837 "./asn1/h225/h225.cnf"
#line 835 "./asn1/h225/h225.cnf"
actx->private_data = parent_gefx;
return offset;
@ -4050,7 +4050,7 @@ static const per_sequence_t GenericData_sequence[] = {
int
dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 818 "./asn1/h225/h225.cnf"
#line 816 "./asn1/h225/h225.cnf"
void *priv_data = actx->private_data;
gef_ctx_t *gefx;
@ -4064,7 +4064,7 @@ dissect_h225_GenericData(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
ett_h225_GenericData, GenericData_sequence);
#line 828 "./asn1/h225/h225.cnf"
#line 826 "./asn1/h225/h225.cnf"
actx->private_data = priv_data;
return offset;
@ -4103,13 +4103,13 @@ dissect_h225_CircuitInfo(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
static int
dissect_h225_FeatureDescriptor(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 842 "./asn1/h225/h225.cnf"
#line 840 "./asn1/h225/h225.cnf"
void *priv_data = actx->private_data;
actx->private_data = gef_ctx_alloc(NULL, "FeatureDescriptor");
offset = dissect_h225_GenericData(tvb, offset, actx, tree, hf_index);
#line 845 "./asn1/h225/h225.cnf"
#line 843 "./asn1/h225/h225.cnf"
actx->private_data = priv_data;
return offset;
@ -5105,7 +5105,7 @@ dissect_h225_CallLinkage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_
static int
dissect_h225_T_messageContent_item(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 760 "./asn1/h225/h225.cnf"
#line 758 "./asn1/h225/h225.cnf"
tvbuff_t *next_tvb = NULL;
offset = dissect_per_octet_string(tvb, offset, actx, tree, hf_index,
@ -5141,7 +5141,7 @@ static const per_sequence_t T_tunnelledSignallingMessage_sequence[] = {
static int
dissect_h225_T_tunnelledSignallingMessage(tvbuff_t *tvb _U_, int offset _U_, asn1_ctx_t *actx _U_, proto_tree *tree _U_, int hf_index _U_) {
#line 758 "./asn1/h225/h225.cnf"
#line 756 "./asn1/h225/h225.cnf"
tp_handle = NULL;
offset = dissect_per_sequence(tvb, offset, actx, tree, hf_index,
@ -11762,7 +11762,8 @@ void proto_register_h225(void) {
NULL,
sizeof(h225_stat_fields)/sizeof(stat_tap_table_item), h225_stat_fields,
sizeof(h225_stat_params)/sizeof(tap_param), h225_stat_params,
NULL
NULL,
0
};
module_t *h225_module;

View File

@ -1060,7 +1060,8 @@ proto_register_mtp3(void)
NULL,
sizeof(mtp3_stat_fields)/sizeof(stat_tap_table_item), mtp3_stat_fields,
sizeof(mtp3_stat_params)/sizeof(tap_param), mtp3_stat_params,
NULL
NULL,
0
};
/* Register the protocol name and description */

View File

@ -4354,7 +4354,8 @@ proto_register_rpc(void)
NULL,
sizeof(rpc_prog_stat_fields)/sizeof(stat_tap_table_item), rpc_prog_stat_fields,
sizeof(rpc_prog_stat_params)/sizeof(tap_param), rpc_prog_stat_params,
NULL
NULL,
0
};
proto_rpc = proto_register_protocol("Remote Procedure Call", "RPC", "rpc");

View File

@ -6573,7 +6573,8 @@ void proto_register_sip(void)
NULL,
sizeof(sip_stat_fields)/sizeof(stat_tap_table_item), sip_stat_fields,
sizeof(sip_stat_params)/sizeof(tap_param), sip_stat_params,
NULL
NULL,
0
};
/* UAT for header fields */

View File

@ -7335,7 +7335,8 @@ proto_register_sir(void)
NULL,
sizeof(wsp_stat_fields)/sizeof(stat_tap_table_item), wsp_stat_fields,
sizeof(wsp_stat_params)/sizeof(tap_param), wsp_stat_params,
NULL
NULL,
0
};

View File

@ -149,6 +149,7 @@ typedef struct _stat_tap_table_ui {
size_t nparams; /* number of parameters */
tap_param *params; /* pointer to table of parameter info */
GArray *tables; /* An array of stat_tap_table* */
guint refcount; /* a reference count for deallocation */
} stat_tap_table_ui;

View File

@ -158,6 +158,7 @@ SimpleStatisticsDialog::SimpleStatisticsDialog(QWidget &parent, CaptureFile &cf,
TapParameterDialog(parent, cf, help_topic),
stu_(stu)
{
stu->refcount++;
setWindowSubtitle(stu_->title);
loadGeometry(0, 0, stu_->title);
@ -285,7 +286,15 @@ void SimpleStatisticsDialog::fillTree()
tapDraw(&stat_data);
removeTapListeners();
free_stat_tables(stu_, NULL, NULL);
}
SimpleStatisticsDialog::~SimpleStatisticsDialog()
{
stu_->refcount--;
if (stu_->refcount == 0) {
if (stu_->tables)
free_stat_tables(stu_, NULL, NULL);
}
}
/*

View File

@ -49,6 +49,8 @@ private:
static void tapReset(void *sd_ptr);
static void tapDraw(void *sd_ptr);
~SimpleStatisticsDialog();
private slots:
virtual void fillTree();