diff options
author | Vasil Velichkov <vvvelichkov@gmail.com> | 2018-08-26 18:33:36 +0300 |
---|---|---|
committer | Michael Mann <mmann78@netscape.net> | 2018-10-21 11:37:49 +0000 |
commit | 95614f219f4af7160423dfca8a8b316964d64c3b (patch) | |
tree | 20740e3f066a31e9d1733412bcccd6814ad3205f /epan/tap.c | |
parent | d9b3c056d10fbb5c9e69fe1c07a045bb8ad65967 (diff) |
tap-follow: fix memory leak
Register the follow_free as a finish callback.
Call the tap's finish callback in free_tap_listener which is called from
both remove_tap_listener and tap_cleanup.
Describe the finish callback in README.tapping
Change-Id: Ie79ce8f39b0ca6d84810d2e3307dcff38b18d3ac
Reviewed-on: https://code.wireshark.org/review/29309
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'epan/tap.c')
-rw-r--r-- | epan/tap.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/epan/tap.c b/epan/tap.c index 5049d2ec3d..36de269192 100644 --- a/epan/tap.c +++ b/epan/tap.c @@ -449,6 +449,15 @@ find_tap_id(const char *name) static void free_tap_listener(tap_listener_t *tl) { + /* The free_tap_listener is called in the error path of + * register_tap_listener (when the dfilter fails to be registered) + * and the finish callback is set after that. + * If this is changed make sure the finish callback is not called + * twice to prevent double-free errors. + */ + if (tl->finish) { + tl->finish(tl->tapdata); + } dfilter_free(tl->code); g_free(tl->fstring); g_free(tl); @@ -616,8 +625,6 @@ remove_tap_listener(void *tapdata) return; } } - if(tl->finish) - tl->finish(tapdata); free_tap_listener(tl); } |