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

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

Re: bug in gawk 3.1.5


From: Aharon Robbins
Subject: Re: bug in gawk 3.1.5
Date: Wed, 07 Dec 2005 05:19:50 +0200

Greetings. Thanks for the bug report and patch. This happens to be
a known problem, and I've already made and posted a fix along these
lines.

I do appreciate your taking the time and trouble to submit a report!

Thanks again,

Arnold

> Date: Tue, 06 Dec 2005 15:49:10 -1000
> From: Adam Greenblatt <address@hidden>
> Subject: bug in gawk 3.1.5
> To: address@hidden
>
> 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]