On Tue, Jul 17, 2007 at 10:30:30PM -0700, chromatic wrote:
> On Tuesday 17 July 2007 21:50:44 [EMAIL PROTECTED] wrote:
> 
> > Modified:
> >    trunk/src/debug.c
> >
> > Log:
> > Reverse a check on a pointer so that we check for NULL first.  Thanks,
> > Coverity!
> >
> > Modified: trunk/src/debug.c
> > ===========================================================================
> >=== --- trunk/src/debug.c    (original)
> > +++ trunk/src/debug.c       Tue Jul 17 21:50:43 2007
> > @@ -344,7 +343,7 @@
> >          PIO_eprintf(interp, "%li  ", line->number);
> >          c = pdb->file->source + line->source_offset;
> >
> > -        while (*c != '\n'  && c)
> > +        while (c && (*c != '\n'))
> >              PIO_eprintf(interp, "%c", *(c++));
> >      }
> 
> That's an improvement, but *can* c actually be NULL here?

Well, it could be all bits zero if pdb->file->source is NULL and
line->source_offset, but that would be binary-identical-to-NULL-by-coincidence
rather than really NULL.

Without seeing any more than the code above, I'd guess that that's what the
Coverity tool actually triggered on, and so the question is should the guard
be on pdb->file->source ?

Nicholas Clark

Reply via email to