]> sigrok.org Git - libsigrok.git/commitdiff
tondaj-sl-814: fix a potential memory leak
authorGerhard Sittig <redacted>
Fri, 9 Feb 2018 18:30:45 +0000 (19:30 +0100)
committerUwe Hermann <redacted>
Fri, 9 Feb 2018 20:37:40 +0000 (21:37 +0100)
Release an allocated device instance in an error path.

This was reported by clang's scan-build.

src/hardware/tondaj-sl-814/api.c

index d7192a213f512477a0aa805c54eb89ac36a51842..bc6fa18e1bbd1987e8eee7ef01d33594d7935709 100644 (file)
@@ -82,8 +82,10 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
        serial = sr_serial_dev_inst_new(conn, serialcomm);
 
-       if (serial_open(serial, SERIAL_RDWR) != SR_OK)
+       if (serial_open(serial, SERIAL_RDWR) != SR_OK) {
+               g_free(sdi);
                return NULL;
+       }
 
        sdi->inst_type = SR_INST_SERIAL;
        sdi->conn = serial;