Skip to content

Commit 18edac4

Browse files
committed
Fix CID 1164623 (Uninitialized scalar field)
Fix it by combining constructor and Init method. Signed-off-by: Stefan Weil <[email protected]>
1 parent 66b71e6 commit 18edac4

File tree

4 files changed

+6
-9
lines changed

4 files changed

+6
-9
lines changed

src/classify/adaptmatch.cpp

-1
Original file line numberDiff line numberDiff line change
@@ -555,7 +555,6 @@ void Classify::InitAdaptiveClassifier(TessdataManager* mgr) {
555555
static_classifier_ = new TessClassifier(false, this);
556556
}
557557

558-
im_.Init(&classify_debug_level);
559558
InitIntegerFX();
560559

561560
AllProtosOn = NewBitVector(MAX_NUM_PROTOS);

src/classify/classify.cpp

+1
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ Classify::Classify()
184184
this->params()),
185185
double_MEMBER(speckle_rating_penalty, 10.0,
186186
"Penalty to add to worst rating for noise", this->params()),
187+
im_(&classify_debug_level),
187188
shape_table_(nullptr),
188189
dict_(this),
189190
static_classifier_(nullptr) {

src/classify/intmatcher.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -667,9 +667,9 @@ int IntegerMatcher::FindBadFeatures(
667667
}
668668

669669

670-
void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level) {
671-
classify_debug_level_ = classify_debug_level;
672-
670+
IntegerMatcher::IntegerMatcher(tesseract::IntParam *classify_debug_level)
671+
: classify_debug_level_(classify_debug_level)
672+
{
673673
/* Initialize table for evidence to similarity lookup */
674674
for (int i = 0; i < SE_TABLE_SIZE; i++) {
675675
uint32_t IntSimilarity = i << (27 - SE_TABLE_BITS);

src/classify/intmatcher.h

+2-5
Original file line numberDiff line numberDiff line change
@@ -93,9 +93,7 @@ class IntegerMatcher {
9393
// Center of Similarity Curve.
9494
static const float kSimilarityCenter;
9595

96-
IntegerMatcher() : classify_debug_level_(nullptr) {}
97-
98-
void Init(tesseract::IntParam *classify_debug_level);
96+
IntegerMatcher(tesseract::IntParam *classify_debug_level);
9997

10098
void Match(INT_CLASS ClassTemplate,
10199
BIT_VECTOR ProtoMask,
@@ -173,13 +171,12 @@ class IntegerMatcher {
173171
bool SeparateDebugWindows);
174172
#endif
175173

176-
177174
private:
175+
tesseract::IntParam *classify_debug_level_;
178176
uint8_t similarity_evidence_table_[SE_TABLE_SIZE];
179177
uint32_t evidence_table_mask_;
180178
uint32_t mult_trunc_shift_bits_;
181179
uint32_t table_trunc_shift_bits_;
182-
tesseract::IntParam *classify_debug_level_;
183180
uint32_t evidence_mult_mask_;
184181
};
185182

0 commit comments

Comments
 (0)