bug-gawk
[Top][All Lists]
Advanced

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

Re: [bug-gawk] Bugs in Gawk


From: Flávio Medeiros
Subject: Re: [bug-gawk] Bugs in Gawk
Date: Sat, 22 Mar 2014 11:18:24 -0300

Hi,

Regarding the third issue in file regcomp.c, I saw that someone changed the code to avoid the possible memory leak in:

Commit id: e888f1834b88270590b7e04d64c03c75863e4565

01. sbcset = (re_bitset_ptr_t) calloc (sizeof (bitset_t), 1);
02. #ifdef RE_ENABLE_I18N
03.  mbcset = (re_charset_t *) calloc (sizeof (re_charset_t), 1);
04. #endif /* RE_ENABLE_I18N */
05. #ifdef RE_ENABLE_I18N
06.  if (BE (sbcset == NULL || mbcset == NULL, 0))
07. #else
08.  if (BE (sbcset == NULL, 0))
09. #endif /* RE_ENABLE_I18N */
10.    {
11.      re_free (sbcset);
12. #ifdef RE_ENABLE_I18N
13.       re_free (mbcset);
14. #endif
15.       *err = REG_ESPACE;
16.     return NULL;
17.    }

The developer adds lines 11, 12, 13, and 14. Okay, these lines avoid the memory leak in variables mbcset and sbcset. However, there is no reason to add line 11 outside the #ifdef code. When macro RE_ENABLE_I18N is not active, sbcset is always NULL.

In my opinion, the best solution would be:

10.    {      
11. #ifdef RE_ENABLE_I18N
12.       re_free (sbcset);
13.       re_free (mbcset);
14. #endif
15.       *err = REG_ESPACE;
16.     return NULL;
17.    }

Regards,
Flávio Medeiros



On Tue, Mar 11, 2014 at 4:45 AM, <address@hidden> wrote:
Eli Zaretskii <address@hidden> wrote:

> > Date: Mon, 10 Mar 2014 20:57:46 -0300
> > From: Flávio Medeiros <address@hidden>
> >
> > 1)
> > FILE: pc/popen.c/v1-popen.c
> > PROBLEM: Memory leak in function scriptify, variable cmd (line 90 -
> > return null) when we set configuration defined(_MSC_VER) ||
> > defined(__MINGW32__).
> >
> >
> > 2)
> > FILE: regcomp.c/v1-regcomp.c
> > PROBLEM: uninitialized variable in function parse_bracket_exp,
> > variable table_size, when we define macro _LIBC. (around line 2692)
> >
> > 3)
> > FILE: regcomp.c/v1-regcomp.c
> > PROBLEM: memory in function parse_bracket_exp, variable mbcset, when
> > we define macro RE_ENABLE_I18N with mbcset == NULL. (around line 2970)
> >
> > Please let me know if it helps.
>
> Thanks.
>
> What version of Gawk did you see these in?  For example, the 1st issue
> no longer exists in the latest version (there's a call to 'free'), and
> the function scriptify is no longer used in the Windows build anyway.
>
> Line numbers also don't seem to be correct.  Perhaps it would be
> better to show the code itself and explain why you think there might
> be a problem there.

I agree - knowing version and seeing code would help. Issue #2 isn't a
problem since gawk does not define _LIBC. I will probably fix it though.

It's harder to see if #3 is an issue because of all the inline code
for the LIBC case, but I suspect it's also not a real problem.

Thanks for sending in the report.

Arnold


reply via email to

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