mirror of
https://git.busybox.net/buildroot.git
synced 2024-12-18 17:53:34 +08:00
32 lines
653 B
Diff
32 lines
653 B
Diff
fix an ugly core on a simple script
|
|
|
|
http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00040.html
|
|
http://lists.gnu.org/archive/html/bug-gnu-utils/2005-08/msg00047.html
|
|
|
|
--- gawk/io.c
|
|
+++ gawk/io.c
|
|
@@ -2480,9 +2480,12 @@
|
|
{
|
|
struct stat sbuf;
|
|
struct open_hook *oh;
|
|
+ int iop_malloced = FALSE;
|
|
|
|
- if (iop == NULL)
|
|
+ if (iop == NULL) {
|
|
emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
|
|
+ iop_malloced = TRUE;
|
|
+ }
|
|
memset(iop, '\0', sizeof(IOBUF));
|
|
iop->flag = 0;
|
|
iop->fd = fd;
|
|
@@ -2495,7 +2498,8 @@
|
|
}
|
|
|
|
if (iop->fd == INVALID_HANDLE) {
|
|
- free(iop);
|
|
+ if (iop_malloced)
|
|
+ free(iop);
|
|
return NULL;
|
|
}
|
|
if (isatty(iop->fd))
|