mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2025-01-18 06:30:14 +08:00
Fix CID 1395882 (Uninitialized scalar variable)
The implementation for ICOORD only allows division by scale != 0. Do the same for FCOORD by asserting that scale != 0.0f, so undefined program behaviour will be caught. Signed-off-by: Stefan Weil <sw@weilnetz.de>
This commit is contained in:
parent
ce6ff20939
commit
9a1f14f2aa
@ -23,6 +23,7 @@
|
||||
#include <cmath> // for sqrt, atan2
|
||||
#include <cstdio>
|
||||
#include "elst.h"
|
||||
#include "errcode.h" // for ASSERT_HOST
|
||||
#include "platform.h" // for DLLSYM
|
||||
|
||||
class FCOORD;
|
||||
@ -730,11 +731,9 @@ operator/ ( //scalar divide
|
||||
const FCOORD & op1, //operands
|
||||
float scale) {
|
||||
FCOORD result; //output
|
||||
|
||||
if (scale != 0) {
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
}
|
||||
ASSERT_HOST(scale != 0.0f);
|
||||
result.xcoord = op1.xcoord / scale;
|
||||
result.ycoord = op1.ycoord / scale;
|
||||
return result;
|
||||
}
|
||||
|
||||
@ -749,10 +748,9 @@ inline FCOORD &
|
||||
operator/= ( //scalar divide
|
||||
FCOORD & op1, //operands
|
||||
float scale) {
|
||||
if (scale != 0) {
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
}
|
||||
ASSERT_HOST(scale != 0.0f);
|
||||
op1.xcoord /= scale;
|
||||
op1.ycoord /= scale;
|
||||
return op1;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user