]> sigrok.org Git - libsigrok.git/commitdiff
hameg-hmo: Fix two potential memory leaks.
authorUwe Hermann <redacted>
Sat, 19 May 2018 19:54:15 +0000 (21:54 +0200)
committerUwe Hermann <redacted>
Sat, 19 May 2018 20:01:21 +0000 (22:01 +0200)
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

index e4c53887e4ececca857129c47ff09bf2298d87a2..8638a790bc56806954dfe017d8b44d7571e44d71 100644 (file)
@@ -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;