Commit ddcd0423 for tesseract
commit ddcd04239a19d3992ecc443dfa0aa025843a6614
Author: Stefan Weil <sw@weilnetz.de>
Date: Fri Nov 13 17:31:00 2026 +0100
ccmain: set all results of ParagraphInfo and Orientation
PageIterator::ParagraphInfo() only set *just before it returned for a
paragraph without a model (e.g. on a page with a single line), so
is_list_item, is_crown and first_line_indent were not set, and
TessPageIteratorParagraphInfo() returned uninitialized values.
PageIterator::Orientation() did not set deskew_angle if there is no
block.
Set defaults for all results.
Fix proposed by the Anthropic OSS Scanner (finding ANT-2026-O6ZIKBZD).
Assisted-by: OpenCode / Claude Fable 5.2 (Anthropic)
Signed-off-by: Stefan Weil <sw@weilnetz.de>
diff --git a/src/ccmain/pageiterator.cpp b/src/ccmain/pageiterator.cpp
index 0fb5b658..87f646e7 100644
--- a/src/ccmain/pageiterator.cpp
+++ b/src/ccmain/pageiterator.cpp
@@ -581,6 +581,7 @@ void PageIterator::Orientation(tesseract::Orientation *orientation,
*orientation = ORIENTATION_PAGE_UP;
*writing_direction = WRITING_DIRECTION_LEFT_TO_RIGHT;
*textline_order = TEXTLINE_ORDER_TOP_TO_BOTTOM;
+ *deskew_angle = 0.0F;
return;
}
auto *block = block_res->block;
@@ -625,7 +626,12 @@ void PageIterator::Orientation(tesseract::Orientation *orientation,
void PageIterator::ParagraphInfo(tesseract::ParagraphJustification *just,
bool *is_list_item, bool *is_crown,
int *first_line_indent) const {
+ // Set default values first, so that every output is defined even when
+ // the current paragraph has no model.
*just = tesseract::JUSTIFICATION_UNKNOWN;
+ *is_list_item = false;
+ *is_crown = false;
+ *first_line_indent = 0;
if (!it_->row() || !it_->row()->row || !it_->row()->row->para() ||
!it_->row()->row->para()->model) {
return;