[simple-scan] fix crash when scanning on lexmark network mfp (MC3224adwe)



commit b4e185775908178ab98ee12c87313b1d9c098ed8
Author: Ailin Nemui <ailin nemui gmail com>
Date:   Sun Oct 4 17:44:55 2020 +0200

    fix crash when scanning on lexmark network mfp (MC3224adwe)

 src/scanner.vala | 22 +++++++++++++---------
 1 file changed, 13 insertions(+), 9 deletions(-)
---
diff --git a/src/scanner.vala b/src/scanner.vala
index becb9fa0..5b704e1d 100644
--- a/src/scanner.vala
+++ b/src/scanner.vala
@@ -662,10 +662,12 @@ public class Scanner : Object
         switch (option.constraint_type)
         {
         case Sane.ConstraintType.RANGE:
-            if (option.type == Sane.ValueType.FIXED)
-                s += " min=%f, max=%f, quant=%d".printf (Sane.UNFIX (option.range.min), Sane.UNFIX 
(option.range.max), (int) option.range.quant);
-            else
-                s += " min=%d, max=%d, quant=%d".printf ((int) option.range.min, (int) option.range.max, 
(int) option.range.quant);
+            if (option.range != null) {
+                if (option.type == Sane.ValueType.FIXED)
+                    s += " min=%f, max=%f, quant=%d".printf (Sane.UNFIX (option.range.min), Sane.UNFIX 
(option.range.max), (int) option.range.quant);
+                else
+                    s += " min=%d, max=%d, quant=%d".printf ((int) option.range.min, (int) option.range.max, 
(int) option.range.quant);
+            }
             break;
         case Sane.ConstraintType.WORD_LIST:
             s += " values=[";
@@ -682,11 +684,13 @@ public class Scanner : Object
             break;
         case Sane.ConstraintType.STRING_LIST:
             s += " values=[";
-            for (var i = 0; option.string_list[i] != null; i++)
-            {
-                if (i != 0)
-                    s += ", ";
-                s += "\"%s\"".printf (option.string_list[i]);
+            if (option.string_list != null) {
+                for (var i = 0; option.string_list[i] != null; i++)
+                {
+                    if (i != 0)
+                        s += ", ";
+                        s += "\"%s\"".printf (option.string_list[i]);
+                }
             }
             s += "]";
             break;


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]