Mail Archives: djgpp-workers/2004/12/08/03:55:14
On Tue, 7 Dec 2004, Juan Manuel Guerrero wrote:
> The important issue here is the to notice that the patch proposed by Esa
> this morning still does not resolve the complete issue. The patch inhibits
> the call to free() in pclose but left the same malign code:
> error:
>
> if (l1->command)
> free(l1->command);
>
> if (temp_name)
> free(temp_name);
>
> in popen().
Did you actually see crashes from freeing temp_name? I don't see how
that could happen, since temp_name will be initialized in any case.
However, freeing the command pointer is completely unnecessary (read
mode doesn't allocate it, write mode jumps there only when it's already
null), so I removed it.
Index: popen.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/stdio/popen.c,v
retrieving revision 1.8
diff -u -r1.8 popen.c
--- popen.c 7 Dec 2004 10:53:51 -0000 1.8
+++ popen.c 8 Dec 2004 08:38:56 -0000
@@ -84,6 +84,8 @@
pl = l1;
/* stick in elements we know already */
+ l1->command = NULL;
+
if ((temp_name = malloc(L_tmpnam)) == NULL)
goto error;
@@ -154,9 +156,6 @@
error:
- if (l1->command)
- free(l1->command);
-
if (temp_name)
free(temp_name);
--
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
- Raw text -