summaryrefslogtreecommitdiff
path: root/debian/patches/03_scanadf_options_fix.patch
blob: 8c1b0c79d77b15f74c61c6622f2f45126f91d8ea (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
Author: <jblache@debian.org>
Description: Get option descriptor 0 before getting the value for option 0.
Index: trunk/src/scanadf.c
===================================================================
--- trunk.orig/src/scanadf.c
+++ trunk/src/scanadf.c
@@ -550,15 +550,33 @@ fetch_options (SANE_Device * device)
   const SANE_Option_Descriptor * opt;
   SANE_Int num_dev_options;
   int i, option_count;
+  SANE_Status status;
 
   /* and now build the full table of long options: */
 
-  sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0);
+  opt = sane_get_option_descriptor (device, 0);
+  if (opt == NULL)
+    {
+      fprintf (stderr, "Could not get option descriptor for option 0\n");
+      exit (1);
+    }
+
+  status = sane_control_option (device, 0, SANE_ACTION_GET_VALUE, &num_dev_options, 0);
+  if (status != SANE_STATUS_GOOD)
+    {
+      fprintf (stderr, "Could not get value for option 0: %s\n", sane_strstatus (status));
+      exit (1);
+    }
 
   option_count = 0;
-  for (i = 0; i < num_dev_options; ++i)
+  for (i = 1; i < num_dev_options; ++i)
     {
       opt = sane_get_option_descriptor (device, i);
+      if (opt == NULL)
+	{
+	  fprintf (stderr, "Could not get option descriptor for option %d\n", i);
+	  exit (1);
+	}
 
       if (!SANE_OPTION_IS_SETTABLE (opt->cap))
 	continue;