From e8d3d6c84378481b5c0b53236e2fb09288e211b1 Mon Sep 17 00:00:00 2001 From: Bert Vermeulen Date: Sun, 29 Jul 2012 03:01:57 +0200 Subject: [PATCH] sr: properly initialize and check on device instance driver field --- device.c | 1 + session.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) 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); }