bug-gnu-utils
[Top][All Lists]
Advanced

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

Re: awk cores on cygwin


From: Aharon Robbins
Subject: Re: awk cores on cygwin
Date: Fri, 12 Aug 2005 13:17:24 +0300

Greetings. Re this:

> Date: Thu, 11 Aug 2005 01:58:57 +0300
> From: Blayer-Gat Alon <address@hidden>
> Subject: awk cores on cygwin
> To: address@hidden
>
> > awk --version
> GNU Awk 3.1.5
>
> > uname -a
> CYGWIN_NT-5.1 IL-TLV-ABLAYER3 1.5.18(0.132/4/2) 2005-07-02 20:30 i686
> unknown unknown Cygwin
>
> > awk '{}' no_such_file
> Aborted (core dumped)
>
>               Alon Blayer-Gat

Thanks for the report. Here is the fix. I will add this to
the test suite, too.

Arnold
-------------------------------------------------------------------
Fri Aug 12 13:10:33 2005  Arnold D. Robbins  <address@hidden>

        * io.c (iop_alloc): Only free `iop' if it was malloc'ed in
        the first place.

--- ../gawk-3.1.5/io.c  2005-07-26 21:07:43.000000000 +0300
+++ io.c        2005-08-12 13:10:28.239852344 +0300
@@ -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))
@@ -2503,7 +2507,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");




reply via email to

[Prev in Thread] Current Thread [Next in Thread]