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.
This commit is contained in:
Gerhard Sittig 2020-08-26 16:46:41 +02:00
parent f403cb9de9
commit 003ad0ab8c
1 changed files with 4 additions and 0 deletions

View File

@ -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;