Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue 1106: [PATCH] Fixed potential usage of uninitialized bool varia… #9

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Issue 1106: [PATCH] Fixed potential usage of uninitialized bool varia…
…ble in textord/tospace.cpp

https://code.google.com/p/tesseract-ocr/issues/detail?id=1106

Reported by ettl.martin78, Feb 11, 2014
Please review the attached patch. It fixes a potential usage of an uninitialized bool variable ('fuzzy_sp'). The fix simply initialized the variable by default to 'FALSE'. Before the fix, the value of 'fuzzy_sp' was not set, but used in the else-branch in line 1107:

          else {
            prev_blanks = blanks;
            prev_fuzzy_sp = fuzzy_sp;
            prev_fuzzy_non = fuzzy_non;
          }

Best regards and many thanks

Feb 11, 2014
#1 ettl.martin78
The updated patch fixes two more uninitialized variable usages in the same function.

Many thanks for reviewing.
  • Loading branch information
orbitcowboy authored and jimregan committed May 13, 2015
commit 57a1e73b537bfcd5f00a51bf4d0059f270d9658e
3 changes: 3 additions & 0 deletions textord/tospace.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -932,6 +932,9 @@ ROW *Textord::make_prop_words(
box_it.set_to_list (row->blob_list ());
word_it.set_to_list (&words);
bol = TRUE;
fuzzy_non = FALSE;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These initializations look redundant to me. They are already initialized at declaration time near line 894.

Having said that, I find the mix of declaration time and non-declaration initializations needlessly complex and think all of these later initializations should get rolled back up into the declarations.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ray addressed that issue after Martin's bug report: commit 9708041 fixes all three cases, so this pull request can be closed.

fuzzy_sp = FALSE;
blanks = 0;
prev_blanks = 0;
prev_fuzzy_sp = FALSE;
prev_fuzzy_non = FALSE;
Expand Down