Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Comments on Should I check if pointer parameters are null pointers?
Post
Should I check if pointer parameters are null pointers?
When writing any form of custom function such as this:
void func (int* a, int* b)
Should I add code to check if a
and b
are null pointers or not?
if(a == NULL)
/* error handling */
When posting code for code reviews, one frequent comment is that such checks against null should be added for robustness. However, these reviewers are then just as often corrected by others telling them to not add such checks because they are bad practice.
What should be done? Is there an universal policy to check or not to check, or should this be done on case-to-case basis?
1 comment thread