Svante Signell, le Tue 12 Apr 2011 21:46:09 +0200, a écrit :
> On Tue, 2011-04-12 at 20:56 +0200, Samuel Thibault wrote:
> > Svante Signell, le Tue 12 Apr 2011 19:27:10 +0200, a écrit :
> > >           return -1 ;
> > >   }
> > >   /* If we reach here, "filename" is not a symbolic link */
> > 
> > And thus we didn't call realpath at all.  I believe the free below
> > shouldn't be done, it's probably only by chance that it doesn't segfault
> > in your test (by being NULL by chance).
> 
> Yes, we did not call realpath but the variable is still declared but not
> malloced. Does that mean we shouldn't free() it?

Of course.

> > > +#ifdef __GNU__
> > > + free (realfilepath);
> > > +#endif
> > >   return openandconvert( filename );
> > >  }
> 
> OK, thanks for your comments. The biggest problem with malloced
> storage, is where to put the free() statements. To do that you need to
> follow the program logic and find out every statement with a possible
> exit. This can be very difficult sometimes, at least I think so.

That's programming...

> Final version??

Seems good to me.

Samuel


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]
Archive: http://lists.debian.org/[email protected]

Reply via email to