]> sigrok.org Git - libsigrok.git/commitdiff
serial-dmm: Fix segfault when no device is used
authorAlexandru Gagniuc <redacted>
Wed, 5 Dec 2012 21:16:52 +0000 (15:16 -0600)
committerUwe Hermann <redacted>
Wed, 5 Dec 2012 23:21:45 +0000 (00:21 +0100)
di was initialized as NULL. If no device covered by this driver
is used, di remains NULL. This causes a segmentation fault when
calling clear_instances().

Check for di being NULL.

Signed-off-by: Alexandru Gagniuc <redacted>
hardware/serial-dmm/api.c

index 8a2d7be2afac42b80fccd924d88801c2d3c56cd9..be240e236c79c38a134118076513a2d898cd7579 100644 (file)
@@ -151,6 +151,10 @@ static int clear_instances(void)
        struct dev_context *devc;
        GSList *l;
 
+       /* di is not necessarily initialized */
+       if (!di)
+               return SR_OK;
+
        if (!(drvc = di->priv))
                return SR_OK;