From ae25286ae44d164d06742752c40386fb9dfa0683 Mon Sep 17 00:00:00 2001 From: Gabriel Ganne Date: Sun, 28 Jan 2024 10:02:30 +0100 Subject: [PATCH] allow recursice call to tcpedit_dlt_cleanup() This is just a quick hack to prevent a double-free should tcpedit_dlt_cleanup() call itself, which can hapen through dlt_jnpr_ether_cleanup() Ref: #813 --- src/tcpedit/plugins/dlt_plugins.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/tcpedit/plugins/dlt_plugins.c b/src/tcpedit/plugins/dlt_plugins.c index 51585378..6b3be880 100644 --- a/src/tcpedit/plugins/dlt_plugins.c +++ b/src/tcpedit/plugins/dlt_plugins.c @@ -442,16 +442,18 @@ void tcpedit_dlt_cleanup(tcpeditdlt_t *ctx) { tcpeditdlt_plugin_t *plugin; + tcpeditdlt_plugin_t *plugin_orig; assert(ctx); - plugin = ctx->plugins; + plugin_orig = plugin = ctx->plugins; + ctx->plugins = NULL; while (plugin != NULL) { plugin->plugin_cleanup(ctx); plugin = plugin->next; } - plugin = ctx->plugins; + plugin = plugin_orig;; while (plugin != NULL) { tcpeditdlt_plugin_t *plugin_next = plugin->next; safe_free(plugin);