Mail Archives: djgpp-workers/2004/12/07/06:02:49
On Mon, 6 Dec 2004, Juan Manuel Guerrero wrote:
> diff -arNU5 djgpp.orig/src/libc/posix/stdio/popen.c djgpp/src/libc/posix/stdio/popen.c
> --- djgpp.orig/src/libc/posix/stdio/popen.c 2004-11-30 05:08:20.000000000 +0000
> +++ djgpp/src/libc/posix/stdio/popen.c 2004-12-04 18:24:54.000000000 +0000
> @@ -76,10 +76,11 @@
> char *temp_name;
>
> /* make new node */
> if ((l1 = malloc(sizeof(*l1))) == NULL)
> return NULL;
> + l1->command = NULL;
I just committed a different patch (mostly because I think the real bug
is trying to free the command pointer in read mode at all):
Index: popen.c
===================================================================
RCS file: /cvs/djgpp/djgpp/src/libc/posix/stdio/popen.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- popen.c 29 Nov 2004 08:37:03 -0000 1.7
+++ popen.c 7 Dec 2004 10:53:51 -0000 1.8
@@ -232,6 +232,10 @@
/* close duplicate stdin */
close(fd);
+
+ exit:
+
+ free(l1->command);
}
/* if pipe was opened to read, return the exit status we saved */
else if (l1->mode[0] == 'r')
@@ -245,11 +249,6 @@
/* invalid mode */
retval = -1;
- exit:
-
- if (l1->command)
- free(l1->command);
-
free(l1);
return retval;
--
Esa Peuha
student of mathematics at the University of Helsinki
http://www.helsinki.fi/~peuha/
- Raw text -