-
Notifications
You must be signed in to change notification settings - Fork 9.5k
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
Potential Null Pointer Dereference in Function RecodeBeamSearch::ContinueContext
#4247
Comments
I never had a NULL pointer deference in this function and never saw a bug report which reported one. Therefore I think the checks should be removed. Do you want to send a pull request? |
Yeah, I have send a pull request. |
From the name |
But if the for loop is entered and |
Yes, but obviously the loop always terminates before the nullptr is reached. Otherwise we'd have lots of Tesseract crashes. |
From and remove checks from inside the loop. |
@egorpugin, would you prefer the nullptr check in the for statement although that case never occurred up to now? |
I just did a test with |
Yes. And more than that is a question about this issue at all. Just do a quick refactor of cond inside for loop and that's enough. So, checking it for nullptr in the for statement LGTM. |
I updated the PR. Please review. |
Current Behavior
In the Function
RecodeBeamSearch::ContinueContext
, If the condition on line 906 is false, then theprevious=previous->prev
statement at the end of each iteration of thefor
loop will lead to a null pointer dereference.tesseract/src/lstm/recodebeam.cpp
Lines 901 to 910 in 5d5a633
Suggested Fix
If
previous
could be nullptr, an error handling branch should be added, as shown below:If
previous
cannot be nullptr, maybe can remove the check forprevious
, as shown below:The text was updated successfully, but these errors were encountered: