Make epan_free a no-op if the pointer is NULL. This fixes 99% of the cases
causing problems for wmem_leave_file_scope() - remove that XXX comment and add
back the assertion.

Remove the cleanup_dissection call from epan_cleanup, it doesn't make sense
there. init_dissection is only called from epan_new, so cleanup_dissection
should only be called from epan_free.

Add one missing epan_free call to tshark revealed by the above changes.

svn path=/trunk/; revision=51342
This commit is contained in:
Evan Huus 2013-08-13 22:41:34 +00:00
parent 1eab806d9b
commit d8f00e22e1
3 changed files with 7 additions and 15 deletions

View File

@ -123,7 +123,6 @@ epan_init(void (*register_all_protocols_func)(register_cb cb, gpointer client_da
void
epan_cleanup(void)
{
cleanup_dissection();
dfilter_cleanup();
proto_cleanup();
prefs_cleanup();
@ -184,10 +183,12 @@ epan_get_frame_ts(const epan_t *session, guint32 frame_num)
void
epan_free(epan_t *session)
{
/* XXX, it should take session as param */
cleanup_dissection();
if (session) {
/* XXX, it should take session as param */
cleanup_dissection();
g_slice_free(epan_t, session);
g_slice_free(epan_t, session);
}
}
void

View File

@ -106,18 +106,8 @@ wmem_enter_file_scope(void)
void
wmem_leave_file_scope(void)
{
/* XXX: cleanup_dissection (the current caller of this function) is
* itself sometimes called when no file exists to be cleaned up. It's not
* a huge problem really, but it means that we can't assert
* file_scope->in_scope here because it's not always true.
*
* At some point the code should be fixed so that cleanup_dissection is
* only ever called when it's really needed.
*
* g_assert(file_scope->in_scope);
*/
g_assert(file_scope);
g_assert(file_scope->in_scope);
g_assert(!packet_scope->in_scope);
wmem_free_all(file_scope);

View File

@ -2084,6 +2084,7 @@ main(int argc, char *argv[])
draw_tap_listeners(TRUE);
funnel_dump_all_text_windows();
epan_free(cfile.epan);
epan_cleanup();
output_fields_free(output_fields);