From 8582ee097c7587e4c016180b63b953c566df76a5 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Fri, 6 Jul 2018 16:53:24 +0200 Subject: [PATCH] Fix CID 1164618 (Uninitialized scalar field) Fix it by combining constructor and Init method. Signed-off-by: Stefan Weil --- src/textord/cjkpitch.cpp | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/src/textord/cjkpitch.cpp b/src/textord/cjkpitch.cpp index 0703406e..1c19c4e1 100644 --- a/src/textord/cjkpitch.cpp +++ b/src/textord/cjkpitch.cpp @@ -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(); } @@ -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()) { @@ -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(); @@ -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();