On Monday 11 March 2002 20:24, Alex Gough wrote:
> On Mon, 11 Mar 2002, Simon Glover wrote:
> 
> >
> >  For more fun in the same vein, try this:
> >
> >   length S0
> >   end
> >
> >  In both cases the problem is that we're not checking the STRING*
> >  pointer passed to the function before we start trying to dereference it.
> >  This seems to be a fairly generic problem in the string functions,
> >  unfortunately - a brief look suggests that string_ord is the only one
> >  doing the right thing.
> 
> I seem to remember someone unpatching a couple of if (NULL == string)
> statements recently.  I'll be blunt and say: DON'T DO THAT.  Defensive
> programming is good, segfaulting is bad, remember?

It depends on what your defending against.  If it's legal, within the 
design, for string to be NULL, then yes, you have to check.  If it's not 
*supposed* to happen - i.e., somebody's implementaton on top of Parrot is 
busted, I'd prefer the segfault.  It makes tracking the problem so much 
easier, 

Logically speaking, I don't think any Parrot string function should take a 
null string - every string should be, at a minimum, empty.  So I'd say ditch 
the guards and let the Parrto squawk its heart out.

-- 
Bryan C. Warnock
[EMAIL PROTECTED]

Reply via email to