hp-3457a: fix potential NULL dereference

Check the active channels' list for not being empty, before
dereferencing pointers.

This was reported by clang's scan-build.
This commit is contained in:
Gerhard Sittig 2018-02-09 19:05:38 +01:00 committed by Uwe Hermann
parent e93ca8a4d6
commit 1674225a2f
1 changed files with 6 additions and 1 deletions

View File

@ -359,8 +359,13 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi)
return SR_ERR_ARG;
}
devc->current_channel = devc->active_channels->data;
devc->num_active_channels = g_slist_length(devc->active_channels);
if (!devc->num_active_channels) {
sr_err("Need at least one active channel!");
g_slist_free(devc->active_channels);
return SR_ERR_ARG;
}
devc->current_channel = devc->active_channels->data;
hp_3457a_select_input(sdi, front_selected ? CONN_FRONT : CONN_REAR);