1761530 - genesys aborts when accessing invalid vector index and built with GLIBCXX_ASSERTIONS
This commit is contained in:
parent
62dc8e3ea6
commit
f67fcd5975
@ -458,6 +458,7 @@ exit 0
|
||||
- 1761145, 1761001, 1761051, 1761234 - genesys backend now needs gcc-c++, it is not built otherwise
|
||||
- 1758886 - CanoScan LiDE scanners supported by genesys backend are not detected
|
||||
- 1760916 - Samsung C460 does not have JPEG support
|
||||
- 1761530 - genesys aborts when accessing invalid vector index and built with GLIBCXX_ASSERTIONS
|
||||
|
||||
* Mon Sep 30 2019 Zdenek Dohnal <zdohnal@redhat.com> - 1.0.28-1
|
||||
- 1.0.28
|
||||
|
56
sane-genesys-vector-glibcxxassert.patch
Normal file
56
sane-genesys-vector-glibcxxassert.patch
Normal file
@ -0,0 +1,56 @@
|
||||
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;
|
||||
}
|
Loading…
Reference in New Issue
Block a user