Prevent null pointer dereference in bwriteprotect macro usage#20
Conversation
Aborts instead of asserts before using the bwriteprotect macro with a null parameter, to avoid null pointer dereference
|
@msteinert Sonar reports now one outstanding bug, in the bwriteprotect macro, which seems legit to my eyes. This PR should protect against this scenario, but Sonar is now reporting 10 new bugs that are clearly spurious, unless I'm overlooking something obvious. Would you mind taking a look at the latest report and tell me what you think? |
|
I wonder if the static analyzer would be less confused if the conditions were combined? if (b0 == NULL || res == NULL) {
ck_abort();
return; /* Just a safeguard */
}
...Granted, this is less useful for debugging a failure. |
ed89a0e to
d759042
Compare
d759042 to
bda23fc
Compare
|
|
This approach actually appeased the static analyzer for three of the cases. I've pushed a commit now that slightly refactors the rest with else statements that cleanly splits out the branches. Still not sure why Sonar picks up on these particular branches. |




Aborts instead of asserts before using the bwriteprotect macro with a null parameter, to avoid null pointer dereference