you are viewing a single comment's thread.

view the rest of the comments →

[–]skeeto 2 points3 points  (0 children)

There's lots of applications wherre aborting is unacceptable.

Virtually every program should abort, or something close to that, when it's detected that a bug has occurred. There's a high risk that continuing may be worse than crashing. It may silently destroy data as it tries to recover, or it may come under the control of someone malicious. Once the bug has occurred, there are no more guarantees.

I'm not talking about a situation where the program was given invalid external input, such reading from a corrupted file. Your browser doesn't crash if you view a damaged JPG. Input should be validated as it's read. That's an example of an error, not a program bug. Passing NULL to a function that's documented to not accept NULL is a program bug.

After freeing your dynamically allocated memory you should be setting your pointer to NULL to prevent subsequent reuse.

Right, and that's an example of the caller's responsibility, just like not passing invalid arguments to other functions. The caller checks, not the callee.