[PATCH] [pls apply!] Bug #54281 (crash): Konsole crashes on output of certain characters

Oswald Buddenhagen ossi at kde.org
Wed Feb 19 14:44:34 GMT 2003


On Wed, Feb 19, 2003 at 12:28:56PM +0100, Karl Vogel wrote:
> Isn't it wise to also check for a NULL pointer?! I know this is an
> illegal combination (ie. buflen>0 and buffer=NULL), but shouldn't core
> functions guard against improper use, instead of dumping core?!
>
no. very often return values are not checked (or the function does not
return anything, in the first place). thus avoiding a segfault at the
library level is equivalent to making the function silently fail.
one more thing to note is, that a null-pointer is only a special case of
an invalid pointer. it's sort of unfair to check only this one. :)
libc functions don't check params, either.
and last but not least, it's a matter of performance (provided a
function is performance-critical, of course).
you can put asserts all over the place, if you're paranoid ... (they
won't be compiled when NDEBUG is #defined).

anyway, it's much better to write application code that does not pass
bad pointers in the first place. :)

greetings

-- 
Hi! I'm a .signature virus! Copy me into your ~/.signature, please!
--
Chaos, panic, and disorder - my work here is done.




More information about the kde-core-devel mailing list