]> sigrok.org Git - libsigrok.git/commitdiff
Quickfix for a segfault with file input via -i.
authorUwe Hermann <redacted>
Sun, 13 Feb 2011 10:27:52 +0000 (11:27 +0100)
committerUwe Hermann <redacted>
Sun, 13 Feb 2011 10:27:52 +0000 (11:27 +0100)
Stuff like

  ./bin/sigrok-cli -i rnd.dd -a transitioncounter

would segfault (rnd.dd consists of random bytes) because device->plugin
was NULL and was being dereferenced.

Thanks Olivier Fauchon <redacted> for reporting.

device.c

index 2dee902cdae15d2f2d9af6f9104e1c2245d63d09..04d463c13e2a9fe34d85a6fe7cdd4095be9ecae8 100644 (file)
--- a/device.c
+++ b/device.c
@@ -235,6 +235,9 @@ gboolean sr_device_has_hwcap(struct sr_device *device, int hwcap)
 {
        int *capabilities, i;
 
+       if (!device || !device->plugin)
+               return;
+
        if ((capabilities = device->plugin->get_capabilities()))
                for (i = 0; capabilities[i]; i++)
                        if (capabilities[i] == hwcap)