Skip to content

Commit

Permalink
Fix CID 1164623 (Uninitialized scalar field)
Browse files Browse the repository at this point in the history
Fix it by combining constructor and Init method.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Jul 6, 2018
1 parent 66b71e6 commit 18edac4
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 9 deletions.
1 change: 0 additions & 1 deletion src/classify/adaptmatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -555,7 +555,6 @@ void Classify::InitAdaptiveClassifier(TessdataManager* mgr) {
static_classifier_ = new TessClassifier(false, this);
}

im_.Init(&classify_debug_level);
InitIntegerFX();

AllProtosOn = NewBitVector(MAX_NUM_PROTOS);
Expand Down
1 change: 1 addition & 0 deletions src/classify/classify.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,7 @@ Classify::Classify()
this->params()),
double_MEMBER(speckle_rating_penalty, 10.0,
"Penalty to add to worst rating for noise", this->params()),
im_(&classify_debug_level),
shape_table_(nullptr),
dict_(this),
static_classifier_(nullptr) {
Expand Down
6 changes: 3 additions & 3 deletions src/classify/intmatcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -667,9 +667,9 @@ int IntegerMatcher::FindBadFeatures(
}


void IntegerMatcher::Init(tesseract::IntParam *classify_debug_level) {
classify_debug_level_ = classify_debug_level;

IntegerMatcher::IntegerMatcher(tesseract::IntParam *classify_debug_level)
: classify_debug_level_(classify_debug_level)
{
/* Initialize table for evidence to similarity lookup */
for (int i = 0; i < SE_TABLE_SIZE; i++) {
uint32_t IntSimilarity = i << (27 - SE_TABLE_BITS);
Expand Down
7 changes: 2 additions & 5 deletions src/classify/intmatcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,7 @@ class IntegerMatcher {
// Center of Similarity Curve.
static const float kSimilarityCenter;

IntegerMatcher() : classify_debug_level_(nullptr) {}

void Init(tesseract::IntParam *classify_debug_level);
IntegerMatcher(tesseract::IntParam *classify_debug_level);

void Match(INT_CLASS ClassTemplate,
BIT_VECTOR ProtoMask,
Expand Down Expand Up @@ -173,13 +171,12 @@ class IntegerMatcher {
bool SeparateDebugWindows);
#endif


private:
tesseract::IntParam *classify_debug_level_;
uint8_t similarity_evidence_table_[SE_TABLE_SIZE];
uint32_t evidence_table_mask_;
uint32_t mult_trunc_shift_bits_;
uint32_t table_trunc_shift_bits_;
tesseract::IntParam *classify_debug_level_;
uint32_t evidence_mult_mask_;
};

Expand Down

0 comments on commit 18edac4

Please sign in to comment.