]> sigrok.org Git - libsigrok.git/blobdiff - src/scpi/scpi.c
scpi-pps: Fix broken channel selection code.
[libsigrok.git] / src / scpi / scpi.c
index 82c95bfc7586850c0f8cd232b78c659707e6779f..3700478692229e7a78813c4058fe608beac93ab7 100644 (file)
@@ -587,6 +587,7 @@ SR_PRIV void sr_scpi_free(struct sr_scpi_dev_inst *scpi)
 
        scpi->free(scpi->priv);
        g_free(scpi->priv);
+       g_free(scpi->actual_channel_name);
        g_free(scpi);
 }
 
@@ -1195,7 +1196,8 @@ SR_PRIV int sr_scpi_cmd(const struct sr_dev_inst *sdi,
        if (channel_cmd && channel_name &&
                        g_strcmp0(channel_name, scpi->actual_channel_name)) {
                sr_spew("sr_scpi_cmd(): new channel = %s", channel_name);
-               scpi->actual_channel_name = channel_name;
+               g_free(scpi->actual_channel_name);
+               scpi->actual_channel_name = g_strdup(channel_name);
                ret = scpi_send(scpi, channel_cmd, channel_name);
                if (ret != SR_OK)
                        return ret;
@@ -1239,7 +1241,8 @@ SR_PRIV int sr_scpi_cmd_resp(const struct sr_dev_inst *sdi,
        if (channel_cmd && channel_name &&
                        g_strcmp0(channel_name, scpi->actual_channel_name)) {
                sr_spew("sr_scpi_cmd_get(): new channel = %s", channel_name);
-               scpi->actual_channel_name = channel_name;
+               g_free(scpi->actual_channel_name);
+               scpi->actual_channel_name = g_strdup(channel_name);
                ret = scpi_send(scpi, channel_cmd, channel_name);
                if (ret != SR_OK)
                        return ret;