From: Gerhard Sittig Date: Sun, 16 May 2021 12:52:49 +0000 (+0200) Subject: scpi-dmm: free memory that was allocated by SCPI get routines X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=83d38ed90a623b7dc4fcd552d6414e34e0828928;p=libsigrok.git scpi-dmm: free memory that was allocated by SCPI get routines The SCPI get routines may allocate memory for response data which callers have to free after use. This addresses part of bug #1683. --- diff --git a/src/hardware/scpi-dmm/protocol.c b/src/hardware/scpi-dmm/protocol.c index 884ba6dc..279aadf5 100644 --- a/src/hardware/scpi-dmm/protocol.c +++ b/src/hardware/scpi-dmm/protocol.c @@ -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++;