]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/fluke-45/protocol.c
fluke-45: free memory that was allocated by SCPI get routines
[libsigrok.git] / src / hardware / fluke-45 / protocol.c
index 5d9c3793e8b119da0c6198c648181845d43908ad..16489007b830aeb02f8f5ce993054a11b8463072 100644 (file)
@@ -332,6 +332,7 @@ SR_PRIV int fl45_scpi_get_response(const struct sr_dev_inst *sdi, char *cmd)
                 * If the response is a prompt then ignore and read the next
                 * response in the buffer.
                 */
                 * If the response is a prompt then ignore and read the next
                 * response in the buffer.
                 */
+               g_free(devc->response);
                devc->response = NULL;
                /* Now attempt to read again. */
                if (sr_scpi_get_string(sdi->conn, NULL, &devc->response) != SR_OK)
                devc->response = NULL;
                /* Now attempt to read again. */
                if (sr_scpi_get_string(sdi->conn, NULL, &devc->response) != SR_OK)
@@ -339,9 +340,10 @@ SR_PRIV int fl45_scpi_get_response(const struct sr_dev_inst *sdi, char *cmd)
        }
 
        /* NULL RS232 error prompts. */
        }
 
        /* NULL RS232 error prompts. */
-       if (strcmp(devc->response, "!>") == 0
-           || (strcmp(devc->response, "?>") == 0)) {
+       if (strcmp(devc->response, "!>") == 0 ||
+           (strcmp(devc->response, "?>") == 0)) {
                /* Unable to execute CMD. */
                /* Unable to execute CMD. */
+               g_free(devc->response);
                devc->response = NULL;
        }
 
                devc->response = NULL;
        }