]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Avoid a double-free.
authorGuido Trentalancia <redacted>
Fri, 16 Nov 2018 17:48:36 +0000 (18:48 +0100)
committerUwe Hermann <redacted>
Thu, 25 Jul 2019 22:11:07 +0000 (00:11 +0200)
Avoid double memory freeing leading to segmentation fault in when a SCPI
command fails to get a string due conditions such as a timeout or an invalid
command.

src/hardware/hameg-hmo/protocol.c

index a69b34f65b455a5b2ac906824b6760b6805e5131..540e85e93d5cade05a750db87a643100cdf0b087 100644 (file)
@@ -439,10 +439,8 @@ static int scope_state_get_array_option(struct sr_scpi_dev_inst *scpi,
        char *tmp;
        int idx;
 
-       if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK) {
-               g_free(tmp);
+       if (sr_scpi_get_string(scpi, command, &tmp) != SR_OK)
                return SR_ERR;
-       }
 
        if ((idx = std_str_idx_s(tmp, *array, n)) < 0) {
                g_free(tmp);