Re: Patch to fix FTBFS of pvm on GNU/Hurd
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.
> 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!
> @@ -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!
Samuel
Reply to: