[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-core-devel
Subject:    Re: [PATCH] [pls apply!] Bug #54281 (crash): Konsole crashes on output of certain characters
From:       Oswald Buddenhagen <ossi () kde ! org>
Date:       2003-02-19 14:44:34
[Download RAW message or body]

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.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic