-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Closed
Copy link
Description
Current Behavior
In the Function RecodeBeamSearch::ContinueContext
, If the condition on line 906 is false, then the previous=previous->prev
statement at the end of each iteration of the for
loop will lead to a null pointer dereference.
tesseract/src/lstm/recodebeam.cpp
Lines 901 to 910 in 5d5a633
for (int p = length - 1; p >= 0; --p, previous = previous->prev) { | |
while (previous != nullptr && | |
(previous->duplicate || previous->code == null_char_)) { | |
previous = previous->prev; | |
} | |
if (previous != nullptr) { | |
prefix.Set(p, previous->code); | |
full_code.Set(p, previous->code); | |
} | |
} |
Suggested Fix
If previous
could be nullptr, an error handling branch should be added, as shown below:
if (previous != nullptr) {
...
} else {
// Add error handling code here
}
If previous
cannot be nullptr, maybe can remove the check for previous
, as shown below:
while (previous->duplicate || previous->code == null_char_) {
previous = previous->prev;
}
prefix.Set(p, previous->code);
full_code.Set(p, previous->code);
Metadata
Metadata
Assignees
Labels
No labels