1761530 - apply upstream patch

This commit is contained in:
Zdenek Dohnal 2019-10-31 10:25:56 +01:00
parent a78d92f735
commit d73c59b309
2 changed files with 20 additions and 56 deletions

View File

@ -33,7 +33,7 @@
Summary: Scanner access software
Name: sane-backends
Version: 1.0.28
Release: 4%{?dist}
Release: 5%{?dist}
# lib/ is LGPLv2+, backends are GPLv2+ with exceptions
# Tools are GPLv2+, docs are public domain
# see LICENSE for details
@ -457,6 +457,9 @@ exit 0
%{_unitdir}/saned@.service
%changelog
* Thu Oct 31 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.0.28-5
- 1761530 - apply upstream patch
* Fri Oct 18 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.0.28-4
- Ad 1761530 - actually apply the patch...

View File

@ -1,56 +1,17 @@
diff --git a/backend/genesys_low.cc b/backend/genesys_low.cc
index 097375f..20dd3a4 100644
--- a/backend/genesys_low.cc
+++ b/backend/genesys_low.cc
@@ -49,6 +49,11 @@
#include <vector>
+template <typename T>
+T safe_vec_addr(std::vector<T>& vec, int i)
+{
+ return vec.size() >= (unsigned long int)(i+1) ? vec[i] : (T)0;
+}
Genesys_Device::~Genesys_Device()
{
@@ -1209,17 +1214,17 @@ SANE_Status sanei_genesys_generate_gamma_buffer(Genesys_Device * dev,
dev->settings.brightness);
for (int i = 0; i < size; i++)
{
- uint16_t value=rgamma[i];
+ uint16_t value = safe_vec_addr(rgamma, i);
value=lut[value];
gamma[i * 2 + size * 0 + 0] = value & 0xff;
gamma[i * 2 + size * 0 + 1] = (value >> 8) & 0xff;
- value=ggamma[i];
+ value = safe_vec_addr(ggamma, i);
value=lut[value];
gamma[i * 2 + size * 2 + 0] = value & 0xff;
gamma[i * 2 + size * 2 + 1] = (value >> 8) & 0xff;
- value=bgamma[i];
+ value = safe_vec_addr(bgamma, i);
value=lut[value];
gamma[i * 2 + size * 4 + 0] = value & 0xff;
gamma[i * 2 + size * 4 + 1] = (value >> 8) & 0xff;
@@ -1229,15 +1234,15 @@ SANE_Status sanei_genesys_generate_gamma_buffer(Genesys_Device * dev,
{
for (int i = 0; i < size; i++)
{
- uint16_t value=rgamma[i];
+ uint16_t value = safe_vec_addr(rgamma, i);
gamma[i * 2 + size * 0 + 0] = value & 0xff;
gamma[i * 2 + size * 0 + 1] = (value >> 8) & 0xff;
- value=ggamma[i];
+ value = safe_vec_addr(ggamma, i);
gamma[i * 2 + size * 2 + 0] = value & 0xff;
gamma[i * 2 + size * 2 + 1] = (value >> 8) & 0xff;
- value=bgamma[i];
+ value = safe_vec_addr(bgamma, i);
gamma[i * 2 + size * 4 + 0] = value & 0xff;
gamma[i * 2 + size * 4 + 1] = (value >> 8) & 0xff;
diff --git a/backend/genesys.cc b/backend/genesys.cc
index 0368e21..5ec37bc 100644
--- a/backend/genesys.cc
+++ b/backend/genesys.cc
@@ -778,6 +778,12 @@ void sanei_genesys_create_default_gamma_table(Genesys_Device* dev,
size = 4096;
}
max = size - 1;
+ } else if (dev->model->asic_type == GENESYS_GL846
+ || dev->model->asic_type == GENESYS_GL847
+ || dev->model->asic_type == GENESYS_GL848
+ || dev->model->asic_type == GENESYS_GL124) {
+ size = 257;
+ max = 65535;
} else {
size = 256;
max = 65535;