From f3f8afb08c2098d9659757a8e7b8c212a09ddf79 Mon Sep 17 00:00:00 2001 From: Olaf Meeuwissen Date: Sat, 6 May 2017 12:24:13 +0900 Subject: [PATCH] kvs20xx.c: don't assume sane_get_devices() has been called Nor that that function is called with a non-NULL argument. This aligns the implementation with that of kvs40xx.c. Fixes 315625. --- backend/kvs20xx.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/backend/kvs20xx.c b/backend/kvs20xx.c index 955252a3c..8864d7d03 100644 --- a/backend/kvs20xx.c +++ b/backend/kvs20xx.c @@ -156,7 +156,8 @@ sane_get_devices (const SANE_Device *** device_list, known_devices[curr_scan_dev].scanner.model, NULL, -1, -1, -1, -1, attach); } - *device_list = (const SANE_Device **) devlist; + if(device_list) + *device_list = (const SANE_Device **) devlist; return SANE_STATUS_GOOD; } @@ -168,6 +169,12 @@ sane_open (SANE_String_Const devname, SANE_Handle * handle) struct scanner *s; SANE_Int h, bus; SANE_Status st; + if (!devlist) + { + st = sane_get_devices (NULL, 0); + if (st) + return st; + } for (i = 0; devlist[i]; i++) { if (!strcmp (devlist[i]->name, devname))