Commit 5cc1d3df for tesseract

commit 5cc1d3dfc1e945929247796fa6edc4913d6c0d6a
Author: Stefan Weil <sw@weilnetz.de>
Date:   Sun Aug 9 13:12:58 2026 +0200

    Fix CID 1487954, 1660580 (Uninitialized scalar variable)

    Initialize all pointer members of PAGE_RES_IT.
    Use the constructor which takes the PAGE_RES instead of default
    construction followed by manual initialization.

    Assisted-by: OpenCode / big-pickle (opencode)
    Signed-off-by: Stefan Weil <sw@weilnetz.de>

diff --git a/src/ccmain/recogtraining.cpp b/src/ccmain/recogtraining.cpp
index 02c60a6d..eeb667b6 100644
--- a/src/ccmain/recogtraining.cpp
+++ b/src/ccmain/recogtraining.cpp
@@ -98,9 +98,7 @@ void Tesseract::recog_training_segmented(const char *filename, PAGE_RES *page_re
     ASSERT_HOST(box_file);
   }

-  PAGE_RES_IT page_res_it;
-  page_res_it.page_res = page_res;
-  page_res_it.restart_page();
+  PAGE_RES_IT page_res_it(page_res);
   std::string label;

   // Process all the words on this page.
diff --git a/src/ccstruct/pageres.h b/src/ccstruct/pageres.h
index 63759488..f37b4df0 100644
--- a/src/ccstruct/pageres.h
+++ b/src/ccstruct/pageres.h
@@ -681,7 +681,7 @@ public:

 class TESS_API PAGE_RES_IT {
 public:
-  PAGE_RES *page_res; // page being iterated
+  PAGE_RES *page_res = nullptr; // page being iterated

   PAGE_RES_IT() = default;

@@ -784,17 +784,17 @@ public:
 private:
   WERD_RES *internal_forward(bool new_block, bool empty_ok);

-  WERD_RES *prev_word_res;   // previous word
-  ROW_RES *prev_row_res;     // row of prev word
-  BLOCK_RES *prev_block_res; // block of prev word
+  WERD_RES *prev_word_res = nullptr; // previous word
+  ROW_RES *prev_row_res = nullptr;   // row of prev word
+  BLOCK_RES *prev_block_res = nullptr; // block of prev word

-  WERD_RES *word_res;   // current word
-  ROW_RES *row_res;     // row of current word
-  BLOCK_RES *block_res; // block of cur. word
+  WERD_RES *word_res = nullptr;   // current word
+  ROW_RES *row_res = nullptr;     // row of current word
+  BLOCK_RES *block_res = nullptr; // block of cur. word

-  WERD_RES *next_word_res;   // next word
-  ROW_RES *next_row_res;     // row of next word
-  BLOCK_RES *next_block_res; // block of next word
+  WERD_RES *next_word_res = nullptr;   // next word
+  ROW_RES *next_row_res = nullptr;     // row of next word
+  BLOCK_RES *next_block_res = nullptr; // block of next word

   BLOCK_RES_IT block_res_it; // iterators
   ROW_RES_IT row_res_it;