From 003ad0ab8cfaab20d3037d46c35ae63c7d2a2c42 Mon Sep 17 00:00:00 2001 From: Gerhard Sittig Date: Wed, 26 Aug 2020 16:46:41 +0200 Subject: [PATCH] input/saleae: keep previous channels across cleanup() call The previous implementation of the cleanup() routine in the saleae input module kept user specified options, but lost the previously created list of sigrok channels. Keep it. Also make sure that reset() voids the previous copy after grabbing its value. To not unexpectedly release resources which still get referenced. This shall unbreak file-reload. --- src/input/saleae.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/input/saleae.c b/src/input/saleae.c index d16b96c4..cc954e62 100644 --- a/src/input/saleae.c +++ b/src/input/saleae.c @@ -1067,6 +1067,7 @@ static void cleanup(struct sr_input *in) { struct context *inc; struct context_options save_opts; + GSList *save_channels; if (!in) return; @@ -1084,8 +1085,10 @@ static void cleanup(struct sr_input *in) /* Clear internal state, but keep what .init() has provided. */ save_opts = inc->options; + save_channels = inc->module_state.prev_channels; memset(inc, 0, sizeof(*inc)); inc->options = save_opts; + inc->module_state.prev_channels = save_channels; } static int reset(struct sr_input *in) @@ -1104,6 +1107,7 @@ static int reset(struct sr_input *in) */ cleanup(in); in->sdi->channels = inc->module_state.prev_channels; + inc->module_state.prev_channels = NULL; inc->module_state.got_header = FALSE; inc->module_state.header_sent = FALSE;