-
-
Notifications
You must be signed in to change notification settings - Fork 98
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
Fix a few issues detected with static code analysis #131
Fix a few issues detected with static code analysis #131
Conversation
All other calls to memory_map_fixed() are checked, and this one may also theoretically fail.
It's the region pointer that can be NULL here, and p was checked at the beginning of the function. Also fix the test accordingly.
It's the region pointer that can be NULL here, and p was checked at the beginning of the function.
@@ -903,7 +903,10 @@ static int regions_grow(void) { | |||
} | |||
} | |||
|
|||
memory_map_fixed(ra->regions, ra->total * sizeof(struct region_metadata)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This call shouldn't be checked because failure doesn't impact whether the function succeeded. It doesn't really matter if it succeeds. The point of doing this is to free memory.
I've cherry-picked the other 2 commits. I reworded the commit messages to explain what was wrong in both cases. The The |
The |
Alright, maybe a comment would help clarify this for future source code reviews/analyses, but thanks for the explanation! |
Static code analysis of hardened_malloc flagged some small issues. This pull request proposes fixes for three of them, and I'll open an issue to discuss the remaining ones, if that's OK for you.