If SANE returns empty device list treat it as an error

Dmitry Timoshkov dmitry at baikal.ru
Thu Nov 17 09:11:11 CST 2005


Hello,

my system has no scanners installed and sane_get_devices returns
empty list with status SANE_STATUS_GOOD. We should not neither return
success in that case nor set DSM_currentDevice to 1 as the very next
call to TWAIN_IdentityGetNext crashes trying to access device #1 which
doesn't exist.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    If SANE returns empty device list treat it as an error.

--- cvs/hq/wine/dlls/twain/dsm_ctrl.c	2005-09-07 20:08:50.000000000 +0900
+++ wine/dlls/twain/dsm_ctrl.c	2005-11-17 22:53:00.000000000 +0800
@@ -146,16 +146,24 @@ TW_UINT16 TWAIN_IdentityGetFirst (pTW_ID
     {
         if (device_list[0])
         {
+            TRACE("got: %s, %s, %s\n", device_list[0]->name, device_list[0]->vendor, device_list[0]->model);
             pSourceIdentity->Id = DSM_sourceId ++;
             strcpy (pSourceIdentity->ProductName, device_list[0]->name);
             strcpy (pSourceIdentity->Manufacturer, device_list[0]->vendor);
             strcpy (pSourceIdentity->ProductFamily, device_list[0]->model);
             pSourceIdentity->ProtocolMajor = TWON_PROTOCOLMAJOR;
             pSourceIdentity->ProtocolMinor = TWON_PROTOCOLMINOR;
+
+            DSM_currentDevice = 1;
+            twRC = TWRC_SUCCESS;
+            DSM_twCC = TWCC_SUCCESS;
+        }
+        else
+        {
+            TRACE("got empty device list\n");
+            twRC = TWRC_FAILURE;
+            DSM_twCC = TWCC_NODS;
         }
-        DSM_currentDevice = 1;
-        twRC = TWRC_SUCCESS;
-        DSM_twCC = TWCC_SUCCESS;
     }
     else if (status == SANE_STATUS_NO_MEM)
     {






More information about the wine-patches mailing list