Revert "diameter: fix 400kb leaked memory on exit"

This reverts commit a04b6fcb3d.

Temporary revert to see if this prevents the "tshark -G" crashes being seen on the 64-bit Windows buildbot.

Change-Id: I561439039ca2667b72d7e2319a6f3f5f97e18d15
Reviewed-on: https://code.wireshark.org/review/17412
Reviewed-by: Guy Harris <guy@alum.mit.edu>
This commit is contained in:
Guy Harris 2016-08-31 07:42:31 +00:00
parent c8869f68db
commit 5fea2b5f41
2 changed files with 9 additions and 38 deletions

View File

@ -749,8 +749,8 @@ ddict_scan(const char* system_directory, const char* filename, int dbg)
state.dict = g_new(ddict_t,1);
state.dict->applications = NULL;
state.dict->vendors = NULL;
state.dict->cmds = NULL;
state.dict->vendors = NULL;
state.dict->typedefns = NULL;
state.dict->avps = NULL;
state.dict->xmlpis = NULL;
@ -796,7 +796,6 @@ ddict_scan(const char* system_directory, const char* filename, int dbg)
}
if (DiamDict_lex_init(&scanner) != 0) {
/* Note: cannot be reached since memory allocation failure terminates early */
D(("Can't initialize scanner: %s\n", g_strerror(errno)));
fclose(in);
g_free(state.dict);
@ -828,7 +827,6 @@ ddict_scan(const char* system_directory, const char* filename, int dbg)
state.current_yyinput = string_input;
if (DiamDict_lex_init(&scanner) != 0) {
/* Note: cannot be reached since memory allocation failure terminates early */
D(("Can't initialize scanner: %s\n", g_strerror(errno)));
g_free(state.dict);
g_free(state.strbuf);
@ -842,16 +840,6 @@ ddict_scan(const char* system_directory, const char* filename, int dbg)
DiamDict_lex(scanner);
DiamDict_lex_destroy(scanner);
{
entity_t *e, *en;
for (e = state.ents; e; e = en) {
en = e->next;
g_free(e->name);
g_free(e->file);
g_free(e);
}
}
g_free(state.strbuf);
return state.dict;
@ -865,9 +853,8 @@ ddict_free(ddict_t* d)
ddict_cmd_t *c, *cn;
ddict_typedefn_t *t, *tn;
ddict_avp_t *a, *an;
ddict_xmlpi_t *x, *xn;
#define FREE_NAMEANDOBJ(n) do { g_free(n->name); g_free(n); } while(0)
#define FREE_NAMEANDOBJ(n) do { if(n->name) g_free(n->name); g_free(n); } while(0)
for (p = d->applications; p; p = pn ) {
pn = p->next;
@ -876,19 +863,18 @@ ddict_free(ddict_t* d)
for (v = d->vendors; v; v = vn) {
vn = v->next;
g_free(v->desc);
if (v->desc) g_free(v->desc);
FREE_NAMEANDOBJ(v);
}
for (c = d->cmds; c; c = cn ) {
cn = c->next;
g_free(c->vendor);
FREE_NAMEANDOBJ(c);
}
for (t = d->typedefns; t; t = tn) {
tn = t->next;
g_free(t->parent);
if (t->parent) g_free(t->parent);
FREE_NAMEANDOBJ(t);
}
@ -907,19 +893,12 @@ ddict_free(ddict_t* d)
FREE_NAMEANDOBJ(e);
}
g_free(a->vendor);
g_free(a->type);
g_free(a->description);
if (a->vendor) g_free(a->vendor);
if (a->type) g_free(a->type);
if (a->description) g_free(a->description);
FREE_NAMEANDOBJ(a);
}
for (x = d->xmlpis; x; x = xn) {
xn = x->next;
g_free(x->key);
g_free(x->value);
FREE_NAMEANDOBJ(x);
}
g_free(d);
}

View File

@ -681,7 +681,7 @@ dissect_diameter_avp(diam_ctx_t *c, tvbuff_t *tvb, int offset, diam_sub_dis_t *d
wmem_array_sort(vendor->vs_avps, compare_avps);
vendor->vs_avps_ext = value_string_ext_new(VND_AVP_VS(vendor),
VND_AVP_VS_LEN(vendor)+1,
wmem_strdup_printf(wmem_epan_scope(), "diameter_vendor_%s",
g_strdup_printf("diameter_vendor_%s",
val_to_str_ext_const(vendorid,
&sminmpec_values_ext,
"Unknown")));
@ -1847,14 +1847,6 @@ strcase_equal(gconstpointer ka, gconstpointer kb)
return g_ascii_strcasecmp(a,b) == 0;
}
static gboolean
ddict_cleanup_cb(wmem_allocator_t* allocator _U_, wmem_cb_event_t event _U_, void *user_data)
{
ddict_t *d = (ddict_t *)user_data;
ddict_free(d);
return FALSE;
}
/* Note: Dynamic "value string arrays" (e.g., vs_cmds, vs_avps, ...) are constructed using */
/* "zero-terminated" GArrays so that they will have the same form as standard */
@ -1913,6 +1905,7 @@ dictionary_load(void)
/* load the dictionary */
dir = wmem_strdup_printf(NULL, "%s" G_DIR_SEPARATOR_S "diameter" G_DIR_SEPARATOR_S, get_datafile_dir());
/* XXX We don't call ddict_free anywhere. */
d = ddict_scan(dir,"dictionary.xml",do_debug_parser);
wmem_free(NULL, dir);
if (d == NULL) {
@ -1920,7 +1913,6 @@ dictionary_load(void)
g_array_free(vnd_shrt_arr, TRUE);
return 0;
}
wmem_register_callback(wmem_epan_scope(), ddict_cleanup_cb, d);
if (do_dump_dict) ddict_print(stdout, d);