[Zlib-devel] [PATCH] Fix segfault when NULL is passed as path to gzopen*
jbowler at acm.org
jbowler at acm.org
Wed Dec 15 18:54:03 EST 2010
From: zlib-devel-bounces at madler.net [mailto:zlib-devel-bounces at madler.net] On Behalf Of Mike Frysinger
>here's an idea ... dont call gzopen() with NULL -mike
Yes, it's rather difficult to justify the suggested change because the crash happens inside 'strlen', so if anything should be checking for NULL it's that function (NULL is no less valid to gzopen than it is to strlen.)
On the other hand, in one large project I did end up heading every function that had pointer arguments with a sequence of checks for NULL - no warning, no error if the check found a NULL, just return. The reason was that this way if anything crashed it happened in the code that called my function, not my code, and that substantially reduced the number of bugs (the crash was closer to the error.)
John Bowler <jbowler at acm.org>
More information about the Zlib-devel
mailing list