From: Bert Vermeulen Date: Sun, 29 Jul 2012 01:01:57 +0000 (+0200) Subject: sr: properly initialize and check on device instance driver field X-Git-Tag: dsupstream~753 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=e8d3d6c84378481b5c0b53236e2fb09288e211b1;p=libsigrok.git sr: properly initialize and check on device instance driver field --- diff --git a/device.c b/device.c index 53333114..e9f6c7bc 100644 --- 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; diff --git a/session.c b/session.c index e4b8c1c2..23e4e495 100644 --- 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); }