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

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

bug in gawk 3.1.5


From: Adam Greenblatt
Subject: bug in gawk 3.1.5
Date: Tue, 06 Dec 2005 15:49:10 -1000
User-agent: Mozilla Thunderbird 0.9 (X11/20041103)

Hi,
  If you run gawk version 3.1.5 as follows:

$ gawk '{exit}' some-filename-that-is-not-present

You'll get an error message from glibc about freeing a non-malloc'd pointer.
(Newer versions of glibc will actually terminate gawk at this point, before gawk is able to give its "cannot open file `some-filename-that-is-not-present' for reading (No such file or directory)"
error message.)

I think the problem lies in the function iop_alloc in io.c; basically you're freeing pointers to statically allocated data. Here's a fix that worked for me, I hope it helps:

address@hidden 40024 $ diff -Naur io.c.orig io.c
--- io.c.orig   2005-07-26 08:07:43.000000000 -1000
+++ io.c        2005-12-06 15:41:35.000000000 -1000
@@ -2480,9 +2480,12 @@
{
       struct stat sbuf;
       struct open_hook *oh;
+        int allocated_iop = 0;

-       if (iop == NULL)
+        if (iop == NULL) {
               emalloc(iop, IOBUF *, sizeof(IOBUF), "iop_alloc");
+               allocated_iop = 1;
+        }
       memset(iop, '\0', sizeof(IOBUF));
       iop->flag = 0;
       iop->fd = fd;
@@ -2495,7 +2498,8 @@
       }

       if (iop->fd == INVALID_HANDLE) {
-               free(iop);
+               if (allocated_iop)
+                       free(iop);
               return NULL;
       }
       if (isatty(iop->fd))
address@hidden 40025 $

Feel free to email me if you have any further questions about this bug. Thanks for working on gawk!
  Adam Greenblatt (address@hidden)






reply via email to

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