jeff
2015-04-22 21:34:25 UTC
Howdy
I've got a large C codebase that frequently triggers bugs where pointers
that shouldn't be null, somehow end up getting nulled.
It's easy enough to fix up each individual bug when it gets reported,
just by adding a null check:
if
((void*) ptr != (void*)NULL)
{
// existing code that triggered a crash
}
However, as these null conditions only show up occasionally, there always
seem to be more bugs left to find.
My question is: is there a way to deal with all of these problems in one
swoop, by ignoring all code that dereferences a null pointer, i.e. null
dereference becomes a NO-OP instead of triggering an exception. ?
Respectfully,
jeff
I've got a large C codebase that frequently triggers bugs where pointers
that shouldn't be null, somehow end up getting nulled.
It's easy enough to fix up each individual bug when it gets reported,
just by adding a null check:
if
((void*) ptr != (void*)NULL)
{
// existing code that triggered a crash
}
However, as these null conditions only show up occasionally, there always
seem to be more bugs left to find.
My question is: is there a way to deal with all of these problems in one
swoop, by ignoring all code that dereferences a null pointer, i.e. null
dereference becomes a NO-OP instead of triggering an exception. ?
Respectfully,
jeff