36 lines
934 B
Diff
36 lines
934 B
Diff
--- gawk-3.1.5/io.c.free 2005-09-27 19:21:05.000000000 +0200
|
|
+++ gawk-3.1.5/io.c 2005-09-27 19:22:58.000000000 +0200
|
|
@@ -2479,9 +2479,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;
|
|
@@ -2494,7 +2497,8 @@
|
|
}
|
|
|
|
if (iop->fd == INVALID_HANDLE) {
|
|
- free(iop);
|
|
+ if (iop_malloced)
|
|
+ free(iop);
|
|
return NULL;
|
|
}
|
|
if (isatty(iop->fd))
|
|
@@ -2502,7 +2506,7 @@
|
|
iop->readsize = iop->size = optimal_bufsize(iop->fd, & sbuf);
|
|
iop->sbuf = sbuf;
|
|
if (do_lint && S_ISREG(sbuf.st_mode) && sbuf.st_size == 0)
|
|
- lintwarn(_("data file `%s' is empty"), name);
|
|
+ lintwarn(_("data file `%s' is empty"), name);
|
|
errno = 0;
|
|
iop->count = iop->scanoff = 0;
|
|
emalloc(iop->buf, char *, iop->size += 2, "iop_alloc");
|