Merge pull request #1521 from stweil/coverity

Fix CID 1164613 (Uninitialized pointer field)
This commit is contained in:
zdenop 2018-04-23 21:03:52 +02:00 committed by GitHub
commit b6c6cd7aa6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 30 additions and 32 deletions

View File

@ -169,10 +169,6 @@ class DLLSYM ELIST2_ITERATOR
ELIST2_ITERATOR *other_it); //to other current
public:
ELIST2_ITERATOR() { //constructor
list = nullptr;
} //unassigned list
ELIST2_ITERATOR( //constructor
ELIST2 *list_to_iterate);
@ -253,6 +249,9 @@ class DLLSYM ELIST2_ITERATOR
int comparator ( //comparison routine
const void *, const void *));
private:
// Don't use the following constructor.
ELIST2_ITERATOR();
};
/***********************************************************************
@ -922,13 +921,11 @@ ELIST2IZEH_C.
\
class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR { \
public: \
CLASSNAME##_IT() : ELIST2_ITERATOR() {} \
\
CLASSNAME##_IT(CLASSNAME##_LIST *list) : ELIST2_ITERATOR(list) {} \
\
CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \
\
CLASSNAME *data_relative(int8_t offset) { \
CLASSNAME *data_relative(int8_t offset) { \
return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \
} \
\
@ -945,6 +942,8 @@ ELIST2IZEH_C.
CLASSNAME *move_to_last() { \
return (CLASSNAME *)ELIST2_ITERATOR::move_to_last(); \
} \
private: \
CLASSNAME##_IT(); \
};
#define ELIST2IZEH(CLASSNAME) \

View File

@ -35,7 +35,6 @@ EXTERN double_VAR (gapmap_big_gaps, 1.75, "xht multiplier");
GAPMAP::GAPMAP( //Constructor
TO_BLOCK *block //block
) {
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
BLOBNBOX_IT blob_it; //iterator
TBOX blob_box;
@ -48,7 +47,6 @@ GAPMAP::GAPMAP( //Constructor
int16_t max_quantum;
int16_t i;
row_it.set_to_list (block->get_rows ());
/*
Find left and right extremes and bucket size
*/
@ -57,6 +55,9 @@ GAPMAP::GAPMAP( //Constructor
max_right = -INT16_MAX;
total_rows = 0;
any_tabs = FALSE;
// row iterator
TO_ROW_IT row_it(block->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
if (!row->blob_list ()->empty ()) {

View File

@ -297,7 +297,6 @@ void compute_page_skew( //get average gradient
int32_t row_index; //of total
TO_ROW *row; //current row
TO_BLOCK_IT block_it = blocks; //iterator
TO_ROW_IT row_it;
row_count = 0;
blob_count = 0;
@ -308,7 +307,7 @@ void compute_page_skew( //get average gradient
continue; // Pretend non-text blocks don't exist.
row_count += block_it.data ()->get_rows ()->length ();
//count up rows
row_it.set_to_list (block_it.data ()->get_rows ());
TO_ROW_IT row_it(block_it.data()->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ())
blob_count += row_it.data ()->blob_list ()->length ();
}
@ -329,7 +328,7 @@ void compute_page_skew( //get average gradient
POLY_BLOCK* pb = block_it.data()->block->pdblk.poly_block();
if (pb != nullptr && !pb->IsText())
continue; // Pretend non-text blocks don't exist.
row_it.set_to_list (block_it.data ()->get_rows ());
TO_ROW_IT row_it(block_it.data ()->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
blob_count = row->blob_list ()->length ();
@ -359,7 +358,7 @@ void compute_page_skew( //get average gradient
POLY_BLOCK* pb = block_it.data()->block->pdblk.poly_block();
if (pb != nullptr && !pb->IsText())
continue; // Pretend non-text blocks don't exist.
row_it.set_to_list (block_it.data ()->get_rows ());
TO_ROW_IT row_it(block_it.data()->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list ();
row_it.forward ()) {
row = row_it.data ();

View File

@ -67,9 +67,9 @@ TabFind::TabFind(int gridsize, const ICOORD& bleft, const ICOORD& tright,
int resolution)
: AlignedBlob(gridsize, bleft, tright),
resolution_(resolution),
v_it_(&vectors_),
image_origin_(0, tright.y() - 1) {
width_cb_ = nullptr;
v_it_.set_to_list(&vectors_);
v_it_.add_list_after(vlines);
SetVerticalSkewAndParellelize(vertical_x, vertical_y);
width_cb_ = NewPermanentTessCallback(this, &TabFind::CommonWidth);

View File

@ -77,7 +77,6 @@ void compute_fixed_pitch(ICOORD page_tr, // top right
BOOL8 testing_on) { // correct orientation
TO_BLOCK_IT block_it; //iterator
TO_BLOCK *block; //current block;
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
int block_index; //block number
int row_index; //row number
@ -115,7 +114,8 @@ void compute_fixed_pitch(ICOORD page_tr, // top right
block = block_it.data ();
POLY_BLOCK* pb = block->block->pdblk.poly_block();
if (pb != nullptr && !pb->IsText()) continue; // Non-text doesn't exist!
row_it.set_to_list (block->get_rows ());
// row iterator
TO_ROW_IT row_it(block->get_rows());
row_index = 1;
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
@ -152,7 +152,6 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix
int row_index; //number of row
int maxwidth; //max pitch
TO_BLOCK_IT block_it = blocks; //block iterator
TO_ROW_IT row_it;
TO_BLOCK *block; //current block
TO_ROW *row; //current row
float sp_sd; //space deviation
@ -172,7 +171,7 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix
POLY_BLOCK* pb = block->block->pdblk.poly_block();
if (pb != nullptr && !pb->IsText()) continue; // Non text doesn't exist!
row_index = 1;
row_it.set_to_list (block->get_rows ());
TO_ROW_IT row_it(block->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list ();
row_it.forward ()) {
row = row_it.data ();
@ -406,7 +405,6 @@ BOOL8 try_doc_fixed( //determine pitch
//iterator
TO_BLOCK_IT block_it = port_blocks;
TO_BLOCK *block; //current block;
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
int16_t projection_left; //edges
int16_t projection_right;
@ -430,7 +428,8 @@ BOOL8 try_doc_fixed( //determine pitch
|| !textord_blockndoc_fixed)
return FALSE;
shift_factor = gradient / (gradient * gradient + 1);
row_it.set_to_list (block_it.data ()->get_rows ());
// row iterator
TO_ROW_IT row_it(block_it.data ()->get_rows());
master_x = row_it.data ()->projection_left;
master_y = row_it.data ()->baseline.y (master_x);
projection_left = INT16_MAX;
@ -1762,7 +1761,6 @@ void find_repeated_chars(TO_BLOCK *block, // Block to search.
TO_ROW *row;
BLOBNBOX_IT box_it;
BLOBNBOX_IT search_it; // forward search
WERD_IT word_it; // new words
WERD *word; // new word
TBOX word_box; // for plotting
int blobcount, repeated_set;
@ -1777,7 +1775,8 @@ void find_repeated_chars(TO_BLOCK *block, // Block to search.
mark_repeated_chars(row);
}
if (row->num_repeated_sets() == 0) continue; // nothing to do for this row
word_it.set_to_list(&row->rep_words);
// new words
WERD_IT word_it(&row->rep_words);
do {
if (box_it.data()->repeated_set() != 0 &&
!box_it.data()->joined_to_prev()) {

View File

@ -45,7 +45,6 @@ void Textord::to_spacing(
) {
TO_BLOCK_IT block_it; //iterator
TO_BLOCK *block; //current block;
TO_ROW_IT row_it; //row iterator
TO_ROW *row; //current row
int block_index; //block number
int row_index; //row number
@ -77,7 +76,8 @@ void Textord::to_spacing(
(float) block_space_gap_width / block_non_space_gap_width < 3.0) {
block_non_space_gap_width = (int16_t) floor (block_space_gap_width / 3.0);
}
row_it.set_to_list (block->get_rows ());
// row iterator
TO_ROW_IT row_it(block->get_rows());
row_index = 1;
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
@ -123,7 +123,6 @@ void Textord::block_spacing_stats(
int16_t &block_space_gap_width, // resulting estimate
int16_t &block_non_space_gap_width // resulting estimate
) {
TO_ROW_IT row_it; // row iterator
TO_ROW *row; // current row
BLOBNBOX_IT blob_it; // iterator
@ -142,7 +141,8 @@ void Textord::block_spacing_stats(
int32_t end_of_row;
int32_t row_length;
row_it.set_to_list (block->get_rows ());
// row iterator
TO_ROW_IT row_it(block->get_rows());
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
row = row_it.data ();
if (!row->blob_list ()->empty () &&
@ -909,9 +909,7 @@ ROW *Textord::make_prop_words(
C_BLOB_LIST cblobs;
C_BLOB_IT cblob_it = &cblobs;
WERD_LIST words;
WERD_IT word_it; // new words
WERD *word; // new word
WERD_IT rep_char_it; // repeated char words
int32_t next_rep_char_word_right = INT32_MAX;
float repetition_spacing; // gap between repetitions
int32_t xstarts[2]; // row ends
@ -929,7 +927,8 @@ ROW *Textord::make_prop_words(
int16_t next_within_xht_gap = INT16_MAX;
int16_t word_count = 0;
rep_char_it.set_to_list (&(row->rep_words));
// repeated char words
WERD_IT rep_char_it(&(row->rep_words));
if (!rep_char_it.empty ()) {
next_rep_char_word_right =
rep_char_it.data ()->bounding_box ().right ();
@ -938,7 +937,8 @@ ROW *Textord::make_prop_words(
prev_x = -INT16_MAX;
cblob_it.set_to_list (&cblobs);
box_it.set_to_list (row->blob_list ());
word_it.set_to_list (&words);
// new words
WERD_IT word_it(&words);
bol = TRUE;
prev_blanks = 0;
prev_fuzzy_sp = FALSE;
@ -1192,7 +1192,6 @@ ROW *Textord::make_blob_words(
C_BLOB_LIST cblobs;
C_BLOB_IT cblob_it = &cblobs;
WERD_LIST words;
WERD_IT word_it; // new words
WERD *word; // new word
BLOBNBOX *bblob; // current blob
TBOX blob_box; // bounding box
@ -1201,7 +1200,8 @@ ROW *Textord::make_blob_words(
cblob_it.set_to_list(&cblobs);
box_it.set_to_list(row->blob_list());
word_it.set_to_list(&words);
// new words
WERD_IT word_it(&words);
bol = TRUE;
if (!box_it.empty()) {