mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-19 15:03:45 +08:00
Fix crash when function lookup tables are accessed with NaN
Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
863a5b4232
commit
e892cc272f
@ -74,7 +74,7 @@ extern const LUTTempl<kTableSize, LUTFuncLog> LogisticTable;
|
||||
inline double Tanh(double x) {
|
||||
if (x < 0.0) return -Tanh(-x);
|
||||
x *= kScaleFactor;
|
||||
int index = static_cast<int>(x);
|
||||
unsigned index = static_cast<unsigned>(x);
|
||||
if (index >= (kTableSize - 1)) return 1.0;
|
||||
double tanh_i0 = TanhTable[index];
|
||||
double tanh_i1 = TanhTable[index + 1];
|
||||
@ -85,7 +85,7 @@ inline double Tanh(double x) {
|
||||
inline double Logistic(double x) {
|
||||
if (x < 0.0) return 1.0 - Logistic(-x);
|
||||
x *= kScaleFactor;
|
||||
int index = static_cast<int>(x);
|
||||
unsigned index = static_cast<unsigned>(x);
|
||||
if (index >= (kTableSize - 1)) return 1.0;
|
||||
double l0 = LogisticTable[index];
|
||||
double l1 = LogisticTable[index + 1];
|
||||
|
Loading…
Reference in New Issue
Block a user