From: Uwe Hermann Date: Sat, 19 May 2018 19:54:15 +0000 (+0200) Subject: hameg-hmo: Fix two potential memory leaks. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=4fc4b8e7aa63d80bc2d2a032d0126d212d5d46ec;p=libsigrok.git hameg-hmo: Fix two potential memory leaks. Reported by scan-build: src/hardware/hameg-hmo/api.c:533:12: warning: Potential leak of memory pointed to by 'pod_enabled' return SR_ERR; ^~~~~~ --- diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index e4c53887..8638a790 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -529,8 +529,10 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi) (*model->scpi_dialect)[SCPI_CMD_SET_ANALOG_CHAN_STATE], ch->index + 1, ch->enabled); - if (sr_scpi_send(scpi, command) != SR_OK) + if (sr_scpi_send(scpi, command) != SR_OK) { + g_free(pod_enabled); return SR_ERR; + } state->analog_channels[ch->index].state = ch->enabled; setup_changed = TRUE; break; @@ -548,8 +550,10 @@ static int hmo_setup_channels(const struct sr_dev_inst *sdi) (*model->scpi_dialect)[SCPI_CMD_SET_DIG_CHAN_STATE], ch->index, ch->enabled); - if (sr_scpi_send(scpi, command) != SR_OK) + if (sr_scpi_send(scpi, command) != SR_OK) { + g_free(pod_enabled); return SR_ERR; + } state->digital_channels[ch->index] = ch->enabled; setup_changed = TRUE;