Skip to content

Commit

Permalink
Fix CID 1164618 (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 <[email protected]>
  • Loading branch information
stweil committed Jul 6, 2018
1 parent 37f8282 commit 8582ee0
Showing 1 changed file with 10 additions and 12 deletions.
22 changes: 10 additions & 12 deletions src/textord/cjkpitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,11 +915,9 @@ void FPRow::FinalizeLargeChars() {

class FPAnalyzer {
public:
FPAnalyzer(): page_tr_(), rows_() { }
FPAnalyzer(ICOORD page_tr, TO_BLOCK_LIST *port_blocks);
~FPAnalyzer() { }

void Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks);

void Pass1Analyze() {
for (size_t i = 0; i < rows_.size(); i++) rows_[i].Pass1Analyze();
}
Expand Down Expand Up @@ -984,11 +982,14 @@ class FPAnalyzer {
unsigned max_chars_per_row_;
};

void FPAnalyzer::Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks) {
page_tr_ = page_tr;

TO_BLOCK_IT block_it;
block_it.set_to_list (port_blocks);
FPAnalyzer::FPAnalyzer(ICOORD page_tr, TO_BLOCK_LIST *port_blocks)
: page_tr_(page_tr),
num_tall_rows_(0),
num_bad_rows_(0),
num_empty_rows_(0),
max_chars_per_row_(0)
{
TO_BLOCK_IT block_it(port_blocks);

for (block_it.mark_cycle_pt(); !block_it.cycled_list();
block_it.forward()) {
Expand All @@ -999,8 +1000,6 @@ void FPAnalyzer::Init(ICOORD page_tr, TO_BLOCK_LIST *port_blocks) {
}
}

num_empty_rows_ = 0;
max_chars_per_row_ = 0;
for (block_it.mark_cycle_pt(); !block_it.cycled_list();
block_it.forward()) {
TO_ROW_IT row_it = block_it.data()->get_rows();
Expand Down Expand Up @@ -1060,8 +1059,7 @@ void FPAnalyzer::EstimatePitch(bool pass1) {

void compute_fixed_pitch_cjk(ICOORD page_tr,
TO_BLOCK_LIST *port_blocks) {
FPAnalyzer analyzer;
analyzer.Init(page_tr, port_blocks);
FPAnalyzer analyzer(page_tr, port_blocks);
if (analyzer.num_rows() == 0) return;

analyzer.Pass1Analyze();
Expand Down

0 comments on commit 8582ee0

Please sign in to comment.