]> sigrok.org Git - libsigrok.git/commitdiff
scpi-dmm: free memory that was allocated by SCPI get routines
authorGerhard Sittig <redacted>
Sun, 16 May 2021 12:52:49 +0000 (14:52 +0200)
committerGerhard Sittig <redacted>
Sat, 22 May 2021 06:06:58 +0000 (08:06 +0200)
The SCPI get routines may allocate memory for response data which
callers have to free after use.

This addresses part of bug #1683.

src/hardware/scpi-dmm/protocol.c

index 884ba6dcca2a77a337fb96a58d27cbd33473debf..279aadf56410cc78213c6d51361f4df8a129f1e1 100644 (file)
@@ -100,8 +100,10 @@ SR_PRIV int scpi_dmm_get_mq(const struct sr_dev_inst *sdi,
        ret = sr_scpi_get_string(sdi->conn, command, &response);
        if (ret != SR_OK)
                return ret;
-       if (!response || !*response)
+       if (!response || !*response) {
+               g_free(response);
                return SR_ERR_NA;
+       }
        have = response;
        if (*have == '"')
                have++;