Skip to content

Commit 3b69c2b

Browse files
committed
Fix CID 1164613 (Uninitialized pointer field)
This involves removing some constructors without argument. Signed-off-by: Stefan Weil <sw@weilnetz.de>
1 parent d5fb404 commit 3b69c2b

File tree

6 files changed

+30
-32
lines changed

6 files changed

+30
-32
lines changed

ccutil/elst2.h

+6-7
Original file line numberDiff line numberDiff line change
@@ -169,10 +169,6 @@ class DLLSYM ELIST2_ITERATOR
169169
ELIST2_ITERATOR *other_it); //to other current
170170

171171
public:
172-
ELIST2_ITERATOR() { //constructor
173-
list = nullptr;
174-
} //unassigned list
175-
176172
ELIST2_ITERATOR( //constructor
177173
ELIST2 *list_to_iterate);
178174

@@ -253,6 +249,9 @@ class DLLSYM ELIST2_ITERATOR
253249
int comparator ( //comparison routine
254250
const void *, const void *));
255251

252+
private:
253+
// Don't use the following constructor.
254+
ELIST2_ITERATOR();
256255
};
257256

258257
/***********************************************************************
@@ -922,13 +921,11 @@ ELIST2IZEH_C.
922921
\
923922
class DLLSYM CLASSNAME##_IT : public ELIST2_ITERATOR { \
924923
public: \
925-
CLASSNAME##_IT() : ELIST2_ITERATOR() {} \
926-
\
927924
CLASSNAME##_IT(CLASSNAME##_LIST *list) : ELIST2_ITERATOR(list) {} \
928925
\
929926
CLASSNAME *data() { return (CLASSNAME *)ELIST2_ITERATOR::data(); } \
930927
\
931-
CLASSNAME *data_relative(int8_t offset) { \
928+
CLASSNAME *data_relative(int8_t offset) { \
932929
return (CLASSNAME *)ELIST2_ITERATOR::data_relative(offset); \
933930
} \
934931
\
@@ -945,6 +942,8 @@ ELIST2IZEH_C.
945942
CLASSNAME *move_to_last() { \
946943
return (CLASSNAME *)ELIST2_ITERATOR::move_to_last(); \
947944
} \
945+
private: \
946+
CLASSNAME##_IT(); \
948947
};
949948

950949
#define ELIST2IZEH(CLASSNAME) \

textord/gap_map.cpp

+3-2
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ EXTERN double_VAR (gapmap_big_gaps, 1.75, "xht multiplier");
3535
GAPMAP::GAPMAP( //Constructor
3636
TO_BLOCK *block //block
3737
) {
38-
TO_ROW_IT row_it; //row iterator
3938
TO_ROW *row; //current row
4039
BLOBNBOX_IT blob_it; //iterator
4140
TBOX blob_box;
@@ -48,7 +47,6 @@ GAPMAP::GAPMAP( //Constructor
4847
int16_t max_quantum;
4948
int16_t i;
5049

51-
row_it.set_to_list (block->get_rows ());
5250
/*
5351
Find left and right extremes and bucket size
5452
*/
@@ -57,6 +55,9 @@ GAPMAP::GAPMAP( //Constructor
5755
max_right = -INT16_MAX;
5856
total_rows = 0;
5957
any_tabs = FALSE;
58+
59+
// row iterator
60+
TO_ROW_IT row_it(block->get_rows());
6061
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
6162
row = row_it.data ();
6263
if (!row->blob_list ()->empty ()) {

textord/makerow.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,6 @@ void compute_page_skew( //get average gradient
297297
int32_t row_index; //of total
298298
TO_ROW *row; //current row
299299
TO_BLOCK_IT block_it = blocks; //iterator
300-
TO_ROW_IT row_it;
301300

302301
row_count = 0;
303302
blob_count = 0;
@@ -308,7 +307,7 @@ void compute_page_skew( //get average gradient
308307
continue; // Pretend non-text blocks don't exist.
309308
row_count += block_it.data ()->get_rows ()->length ();
310309
//count up rows
311-
row_it.set_to_list (block_it.data ()->get_rows ());
310+
TO_ROW_IT row_it(block_it.data()->get_rows());
312311
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ())
313312
blob_count += row_it.data ()->blob_list ()->length ();
314313
}
@@ -329,7 +328,7 @@ void compute_page_skew( //get average gradient
329328
POLY_BLOCK* pb = block_it.data()->block->pdblk.poly_block();
330329
if (pb != nullptr && !pb->IsText())
331330
continue; // Pretend non-text blocks don't exist.
332-
row_it.set_to_list (block_it.data ()->get_rows ());
331+
TO_ROW_IT row_it(block_it.data ()->get_rows());
333332
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
334333
row = row_it.data ();
335334
blob_count = row->blob_list ()->length ();
@@ -359,7 +358,7 @@ void compute_page_skew( //get average gradient
359358
POLY_BLOCK* pb = block_it.data()->block->pdblk.poly_block();
360359
if (pb != nullptr && !pb->IsText())
361360
continue; // Pretend non-text blocks don't exist.
362-
row_it.set_to_list (block_it.data ()->get_rows ());
361+
TO_ROW_IT row_it(block_it.data()->get_rows());
363362
for (row_it.mark_cycle_pt (); !row_it.cycled_list ();
364363
row_it.forward ()) {
365364
row = row_it.data ();

textord/tabfind.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -67,9 +67,9 @@ TabFind::TabFind(int gridsize, const ICOORD& bleft, const ICOORD& tright,
6767
int resolution)
6868
: AlignedBlob(gridsize, bleft, tright),
6969
resolution_(resolution),
70+
v_it_(&vectors_),
7071
image_origin_(0, tright.y() - 1) {
7172
width_cb_ = nullptr;
72-
v_it_.set_to_list(&vectors_);
7373
v_it_.add_list_after(vlines);
7474
SetVerticalSkewAndParellelize(vertical_x, vertical_y);
7575
width_cb_ = NewPermanentTessCallback(this, &TabFind::CommonWidth);

textord/topitch.cpp

+7-8
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,6 @@ void compute_fixed_pitch(ICOORD page_tr, // top right
7777
BOOL8 testing_on) { // correct orientation
7878
TO_BLOCK_IT block_it; //iterator
7979
TO_BLOCK *block; //current block;
80-
TO_ROW_IT row_it; //row iterator
8180
TO_ROW *row; //current row
8281
int block_index; //block number
8382
int row_index; //row number
@@ -115,7 +114,8 @@ void compute_fixed_pitch(ICOORD page_tr, // top right
115114
block = block_it.data ();
116115
POLY_BLOCK* pb = block->block->pdblk.poly_block();
117116
if (pb != nullptr && !pb->IsText()) continue; // Non-text doesn't exist!
118-
row_it.set_to_list (block->get_rows ());
117+
// row iterator
118+
TO_ROW_IT row_it(block->get_rows());
119119
row_index = 1;
120120
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
121121
row = row_it.data ();
@@ -152,7 +152,6 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix
152152
int row_index; //number of row
153153
int maxwidth; //max pitch
154154
TO_BLOCK_IT block_it = blocks; //block iterator
155-
TO_ROW_IT row_it;
156155
TO_BLOCK *block; //current block
157156
TO_ROW *row; //current row
158157
float sp_sd; //space deviation
@@ -172,7 +171,7 @@ void fix_row_pitch(TO_ROW *bad_row, // row to fix
172171
POLY_BLOCK* pb = block->block->pdblk.poly_block();
173172
if (pb != nullptr && !pb->IsText()) continue; // Non text doesn't exist!
174173
row_index = 1;
175-
row_it.set_to_list (block->get_rows ());
174+
TO_ROW_IT row_it(block->get_rows());
176175
for (row_it.mark_cycle_pt (); !row_it.cycled_list ();
177176
row_it.forward ()) {
178177
row = row_it.data ();
@@ -406,7 +405,6 @@ BOOL8 try_doc_fixed( //determine pitch
406405
//iterator
407406
TO_BLOCK_IT block_it = port_blocks;
408407
TO_BLOCK *block; //current block;
409-
TO_ROW_IT row_it; //row iterator
410408
TO_ROW *row; //current row
411409
int16_t projection_left; //edges
412410
int16_t projection_right;
@@ -430,7 +428,8 @@ BOOL8 try_doc_fixed( //determine pitch
430428
|| !textord_blockndoc_fixed)
431429
return FALSE;
432430
shift_factor = gradient / (gradient * gradient + 1);
433-
row_it.set_to_list (block_it.data ()->get_rows ());
431+
// row iterator
432+
TO_ROW_IT row_it(block_it.data ()->get_rows());
434433
master_x = row_it.data ()->projection_left;
435434
master_y = row_it.data ()->baseline.y (master_x);
436435
projection_left = INT16_MAX;
@@ -1762,7 +1761,6 @@ void find_repeated_chars(TO_BLOCK *block, // Block to search.
17621761
TO_ROW *row;
17631762
BLOBNBOX_IT box_it;
17641763
BLOBNBOX_IT search_it; // forward search
1765-
WERD_IT word_it; // new words
17661764
WERD *word; // new word
17671765
TBOX word_box; // for plotting
17681766
int blobcount, repeated_set;
@@ -1777,7 +1775,8 @@ void find_repeated_chars(TO_BLOCK *block, // Block to search.
17771775
mark_repeated_chars(row);
17781776
}
17791777
if (row->num_repeated_sets() == 0) continue; // nothing to do for this row
1780-
word_it.set_to_list(&row->rep_words);
1778+
// new words
1779+
WERD_IT word_it(&row->rep_words);
17811780
do {
17821781
if (box_it.data()->repeated_set() != 0 &&
17831782
!box_it.data()->joined_to_prev()) {

textord/tospace.cpp

+10-10
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ void Textord::to_spacing(
4545
) {
4646
TO_BLOCK_IT block_it; //iterator
4747
TO_BLOCK *block; //current block;
48-
TO_ROW_IT row_it; //row iterator
4948
TO_ROW *row; //current row
5049
int block_index; //block number
5150
int row_index; //row number
@@ -77,7 +76,8 @@ void Textord::to_spacing(
7776
(float) block_space_gap_width / block_non_space_gap_width < 3.0) {
7877
block_non_space_gap_width = (int16_t) floor (block_space_gap_width / 3.0);
7978
}
80-
row_it.set_to_list (block->get_rows ());
79+
// row iterator
80+
TO_ROW_IT row_it(block->get_rows());
8181
row_index = 1;
8282
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
8383
row = row_it.data ();
@@ -123,7 +123,6 @@ void Textord::block_spacing_stats(
123123
int16_t &block_space_gap_width, // resulting estimate
124124
int16_t &block_non_space_gap_width // resulting estimate
125125
) {
126-
TO_ROW_IT row_it; // row iterator
127126
TO_ROW *row; // current row
128127
BLOBNBOX_IT blob_it; // iterator
129128

@@ -142,7 +141,8 @@ void Textord::block_spacing_stats(
142141
int32_t end_of_row;
143142
int32_t row_length;
144143

145-
row_it.set_to_list (block->get_rows ());
144+
// row iterator
145+
TO_ROW_IT row_it(block->get_rows());
146146
for (row_it.mark_cycle_pt (); !row_it.cycled_list (); row_it.forward ()) {
147147
row = row_it.data ();
148148
if (!row->blob_list ()->empty () &&
@@ -909,9 +909,7 @@ ROW *Textord::make_prop_words(
909909
C_BLOB_LIST cblobs;
910910
C_BLOB_IT cblob_it = &cblobs;
911911
WERD_LIST words;
912-
WERD_IT word_it; // new words
913912
WERD *word; // new word
914-
WERD_IT rep_char_it; // repeated char words
915913
int32_t next_rep_char_word_right = INT32_MAX;
916914
float repetition_spacing; // gap between repetitions
917915
int32_t xstarts[2]; // row ends
@@ -929,7 +927,8 @@ ROW *Textord::make_prop_words(
929927
int16_t next_within_xht_gap = INT16_MAX;
930928
int16_t word_count = 0;
931929

932-
rep_char_it.set_to_list (&(row->rep_words));
930+
// repeated char words
931+
WERD_IT rep_char_it(&(row->rep_words));
933932
if (!rep_char_it.empty ()) {
934933
next_rep_char_word_right =
935934
rep_char_it.data ()->bounding_box ().right ();
@@ -938,7 +937,8 @@ ROW *Textord::make_prop_words(
938937
prev_x = -INT16_MAX;
939938
cblob_it.set_to_list (&cblobs);
940939
box_it.set_to_list (row->blob_list ());
941-
word_it.set_to_list (&words);
940+
// new words
941+
WERD_IT word_it(&words);
942942
bol = TRUE;
943943
prev_blanks = 0;
944944
prev_fuzzy_sp = FALSE;
@@ -1192,7 +1192,6 @@ ROW *Textord::make_blob_words(
11921192
C_BLOB_LIST cblobs;
11931193
C_BLOB_IT cblob_it = &cblobs;
11941194
WERD_LIST words;
1195-
WERD_IT word_it; // new words
11961195
WERD *word; // new word
11971196
BLOBNBOX *bblob; // current blob
11981197
TBOX blob_box; // bounding box
@@ -1201,7 +1200,8 @@ ROW *Textord::make_blob_words(
12011200

12021201
cblob_it.set_to_list(&cblobs);
12031202
box_it.set_to_list(row->blob_list());
1204-
word_it.set_to_list(&words);
1203+
// new words
1204+
WERD_IT word_it(&words);
12051205
bol = TRUE;
12061206
if (!box_it.empty()) {
12071207

0 commit comments

Comments
 (0)