]> sigrok.org Git - libsigrok.git/commitdiff
sr: properly initialize and check on device instance driver field
authorBert Vermeulen <redacted>
Sun, 29 Jul 2012 01:01:57 +0000 (03:01 +0200)
committerBert Vermeulen <redacted>
Fri, 3 Aug 2012 09:29:00 +0000 (11:29 +0200)
device.c
session.c

index 533331141d4908e30ae4e1ee891e6242bab67c75..e9f6c7bcdd661a644221acbd07e5b43804b56365 100644 (file)
--- a/device.c
+++ b/device.c
@@ -194,6 +194,7 @@ SR_PRIV struct sr_dev_inst *sr_dev_inst_new(int index, int status,
                return NULL;
        }
 
+       sdi->driver = NULL;
        sdi->index = index;
        sdi->status = status;
        sdi->inst_type = -1;
index e4b8c1c24d7901feb3c85573338af018c8194528..23e4e49559739d74740ab2b1aacdd74998f1b6d5 100644 (file)
--- a/session.c
+++ b/session.c
@@ -88,7 +88,7 @@ SR_API int sr_session_destroy(void)
 
 static void sr_dev_close(struct sr_dev_inst *sdi)
 {
-       if (sdi->driver->dev_close)
+       if (sdi->driver && sdi->driver->dev_close)
                sdi->driver->dev_close(sdi);
 }