From: Guido Trentalancia Date: Fri, 16 Nov 2018 17:48:36 +0000 (+0100) Subject: hameg-hmo: Avoid a double-free. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=673989692c196907ca41e8003b401c44da67bccc;p=libsigrok.git hameg-hmo: Avoid a double-free. 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. --- diff --git a/src/hardware/hameg-hmo/protocol.c b/src/hardware/hameg-hmo/protocol.c index a69b34f6..540e85e9 100644 --- a/src/hardware/hameg-hmo/protocol.c +++ b/src/hardware/hameg-hmo/protocol.c @@ -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);