From: Martin Atkins Date: Sun, 25 Oct 2020 20:16:37 +0000 (-0700) Subject: scpi-pps: Data capture dynamically-probed channels X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=c54b3726418c8211bf9cb19323b5ba09ad409e1c;p=libsigrok.git scpi-pps: Data capture dynamically-probed channels For the few device profiles that probe the device dynamically to determine channel settings, the results end up in the dynamically-allocated devc->channels instead of in the statically-configured devc->device->channels field. Previously this would crash by dereferencing a null ch_spec for the device types that do dynamic channel configuration. [ gsi: address minor style nits ] --- diff --git a/src/hardware/scpi-pps/protocol.c b/src/hardware/scpi-pps/protocol.c index 9609936a..825fdb94 100644 --- a/src/hardware/scpi-pps/protocol.c +++ b/src/hardware/scpi-pps/protocol.c @@ -97,7 +97,13 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) if (ret != SR_OK) return ret; - ch_spec = &devc->device->channels[pch->hw_output_idx]; + if (devc->channels) { + /* Dynamically-probed devices. */ + ch_spec = &devc->channels[pch->hw_output_idx]; + } else { + /* Statically-configured devices. */ + ch_spec = &devc->device->channels[pch->hw_output_idx]; + } packet.type = SR_DF_ANALOG; packet.payload = &analog; /* Note: digits/spec_digits will be overridden later. */