Re: Patch to fix FTBFS of pvm on GNU/Hurd
On Fri, 2011-04-15 at 20:08 +0200, Samuel Thibault wrote:
> Svante Signell, le Fri 15 Apr 2011 15:55:49 +0200, a écrit :
> > Updated, see patch. What kind of leak is this? path is overwritten by a
> > new malloced array.
>
> And so the old pointer is lost and will never be freed.
OK.
> > Are the potential problems coming from that malloc does not clear the
> > memory allocated,
>
> There is no reason why it should clear previous memory. The malloc
> function can not divine which variable the result will be assigned to!
Understood.
> > @@ -3868,7 +3872,16 @@
> > eplist = CINDEX(name, '/') ? nullep : epaths;
> >
> > for (ep = eplist; *ep; ep++) {
> > +#ifndef __GNU__
> > + free (path);
> > (void)strcpy(path, *ep);
> > +#else
> > + if (path = strdup(*ep) == NULL) {
> > + pvmlogerror("cannot allocate memory\n");
> > + task_free(tp);
> > + return PvmNoFile;
> > + }
> > +#endif
>
>
> Err, no, the free should be before strdup, not before strcpy!
Of course, I'm sorry, this is just a careless mistake of me. I was
correcting exams around the same time this patch was created.
OK, to submit after these changes, or is another review needed?
Reply to: