[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Patch to fix FTBFS of pvm on GNU/Hurd



On 15/04/11 00:10, Samuel Thibault wrote:
> Svante Signell, le Thu 14 Apr 2011 23:18:32 +0200, a écrit :
>> BTW: How to find out which packages build-depends (not depends) on
>> pvm-dev?
> 
> See the graphs on my webpage
> 
> http://people.debian.org/~sthibault/
> 
> 
>> diff -ur pvm-3.4.5/src/pvmd.c pvm-3.4.5.new/src/pvmd.c
>> --- pvm-3.4.5/src/pvmd.c	2011-04-14 22:38:13.000000000 +0200
>> +++ pvm-3.4.5.new/src/pvmd.c	2011-04-14 22:46:26.000000000 +0200
>> @@ -3836,7 +3836,12 @@
>>  	int pid;				/* task pid */
>>  	int pfd[2];				/* pipe back from task */
>>  	struct task *tp;		/* new task context */
>> +
>> +#ifndef __GNU__
>>  	char path[MAXPATHLEN];
>> +#else
>> +	char *path;
>> +#endif
>>  	struct stat sb;
>>  	char **ep, **eplist;
>>  	int i;
>> @@ -3856,10 +3861,16 @@
>>  
>>  	if ((tid = tid_new()) < 0) {
>>  		pvmlogerror("forkexec() out of tids?\n");
>> +#ifdef __GNU__
>> +		free (path);
>> +#endif
>>  		return PvmOutOfRes;
>>  	}
>>  	if ((tp = task_new(tid)) == NULL) {
>>  		pvmlogerror("forkexec() too many tasks?\n");
>> +#ifdef __GNU__
>> +		free (path);
>> +#endif
>>  		return PvmOutOfRes;
>>  	}
> 
> Errr, why frees in these two places?  You haven't assigned any value to
> `path' up to here, so the value is generally random and calling free()
> is thus invalid.
> 
>> @@ -3868,7 +3879,12 @@
>>  	eplist = CINDEX(name, '/') ? nullep : epaths;
>>  
>>  	for (ep = eplist; *ep; ep++) {
>> +#ifndef __GNU__
>>  		(void)strcpy(path, *ep);
>> +#else
>> +		if (path = strdup(*ep) == NULL)
>> +		  pvmlogerror("cannot allocate memory\n");
> 
> and call task_free(tp) and return PvmOutOfRes;
> 
> Also, for now you have a leak: at each iteration of the for loop, path
> will be overwritten by a new strdup(). You could initialize it to NULL
> before the loop and free() it before each strdup() to fix this easily.

And I wouldn't do #ifdef #else #endif, since strdup is portable. Just use it
unconditionally instead of strcpy.

Emilio


Reply to: