From 4fc4b8e7aa63d80bc2d2a032d0126d212d5d46ec Mon Sep 17 00:00:00 2001 From: Uwe Hermann Date: Sat, 19 May 2018 21:54:15 +0200 Subject: [PATCH] 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; ^~~~~~ --- src/hardware/hameg-hmo/api.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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;