Skip to content

Commit 20b3ff8

Browse files
stweilzdenop
authored andcommitted
Fix some minor issues reported by Coverity Scan (#1321)
* Dereference pointer after NULL check (CID 1385638) Move the statement which dereferences the pointer variable "current" after the NULL check. Signed-off-by: Stefan Weil <[email protected]> * Dereference pointer after NULL check (CID 1385635) Move the statement which dereferences the pointer variable "current" after the NULL check. Signed-off-by: Stefan Weil <[email protected]> * Dereference pointer after NULL check (CID 1385634) Move the statement which dereferences the pointer variable "current" after the NULL check. Signed-off-by: Stefan Weil <[email protected]> * Fix CID 1164527 'Constant' variable guards dead code Signed-off-by: Stefan Weil <[email protected]>
1 parent ce7ee87 commit 20b3ff8

File tree

3 files changed

+13
-6
lines changed

3 files changed

+13
-6
lines changed

ccmain/pageiterator.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ void PageIterator::Orientation(tesseract::Orientation *orientation,
540540
: WRITING_DIRECTION_LEFT_TO_RIGHT);
541541

542542
// Textline Order
543-
bool is_mongolian = false; // TODO(eger): fix me
543+
const bool is_mongolian = false; // TODO(eger): fix me
544544
*textline_order = is_vertical_text
545545
? (is_mongolian
546546
? TEXTLINE_ORDER_LEFT_TO_RIGHT

ccutil/clst.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,6 @@ void *CLIST_ITERATOR::forward() {
261261
cycle_pt = next;
262262
current = next;
263263
}
264-
next = current->next;
265264

266265
#ifndef NDEBUG
267266
if (!current)
@@ -270,6 +269,8 @@ void *CLIST_ITERATOR::forward() {
270269
NULL_NEXT.error ("CLIST_ITERATOR::forward", ABORT,
271270
"This is: %p Current is: %p", this, current);
272271
#endif
272+
273+
next = current->next;
273274
return current->data;
274275
}
275276

ccutil/elst2.cpp

+10-4
Original file line numberDiff line numberDiff line change
@@ -204,15 +204,20 @@ ELIST2_LINK *ELIST2_ITERATOR::forward() {
204204
cycle_pt = next;
205205
current = next;
206206
}
207-
next = current->next;
208207

209-
#ifndef NDEBUG
208+
#ifndef NDEBUG
210209
if (!current)
211210
NULL_DATA.error ("ELIST2_ITERATOR::forward", ABORT, NULL);
211+
#endif
212+
213+
next = current->next;
214+
215+
#ifndef NDEBUG
212216
if (!next)
213217
NULL_NEXT.error ("ELIST2_ITERATOR::forward", ABORT,
214218
"This is: %p Current is: %p", this, current);
215-
#endif
219+
#endif
220+
216221
return current;
217222
}
218223

@@ -242,7 +247,6 @@ ELIST2_LINK *ELIST2_ITERATOR::backward() {
242247
cycle_pt = prev;
243248
current = prev;
244249
}
245-
prev = current->prev;
246250

247251
#ifndef NDEBUG
248252
if (!current)
@@ -251,6 +255,8 @@ ELIST2_LINK *ELIST2_ITERATOR::backward() {
251255
NULL_PREV.error ("ELIST2_ITERATOR::backward", ABORT,
252256
"This is: %p Current is: %p", this, current);
253257
#endif
258+
259+
prev = current->prev;
254260
return current;
255261
}
256262

0 commit comments

Comments
 (0)