aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTroy Rollo <troy@kawseq.com>2016-07-31 22:47:25 +1000
committerTroy Rollo <troy@kawseq.com>2016-07-31 22:47:25 +1000
commitb021c3bee8e9edc7854050a3975cef003586b2e5 (patch)
tree74423c43e0077f91fc71625daf71a906b75ff1b4
parent1859803563f8baadeb6c0926610b2f782350d1e4 (diff)
Fix bug 314571 - hp3500 backend does not set correct size for string option.
-rw-r--r--backend/hp3500.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/backend/hp3500.c b/backend/hp3500.c
index ac7aef4..458bbe8 100644
--- a/backend/hp3500.c
+++ b/backend/hp3500.c
@@ -233,6 +233,7 @@ static int reader_process (void *);
static void calculateDerivedValues (struct hp3500_data *scanner);
static void do_reset (struct hp3500_data *scanner);
static void do_cancel (struct hp3500_data *scanner);
+static size_t max_string_size(char const **);
/*
* used by sane_get_devices
@@ -1064,8 +1065,9 @@ init_options (struct hp3500_data *scanner)
opt->title = SANE_TITLE_SCAN_MODE;
opt->desc = SANE_DESC_SCAN_MODE;
opt->type = SANE_TYPE_STRING;
+ opt->size = max_string_size(scan_mode_list);
opt->constraint_type = SANE_CONSTRAINT_STRING_LIST;
- opt->constraint.string_list = scan_mode_list;
+ opt->constraint.string_list = (SANE_String_Const *) scan_mode_list;
opt->cap = SANE_CAP_SOFT_SELECT | SANE_CAP_SOFT_DETECT;
opt = scanner->opt + OPT_BRIGHTNESS;
@@ -3500,3 +3502,20 @@ reader_process (void *pv)
close (scanner->pipe_w);
return status;
}
+
+static size_t
+max_string_size (char const **strings)
+{
+ size_t size, max_size = 0;
+ SANE_Int i;
+
+ for (i = 0; strings[i]; ++i)
+ {
+ size = strlen (strings[i]) + 1;
+ if (size > max_size)
+ max_size = size;
+ }
+ return max_size;
+}
+
+