Patchwork {patch lto-plugin]: Fix memory leak

login
register
mail settings
Submitter Kai Tietz
Date Nov. 13, 2010, 6:41 p.m.
Message ID <AANLkTi=B=vK5O7SK24JT6KZ2Yk78BxEKYt5KrNeW=62G@mail.gmail.com>
Download mbox | patch
Permalink /patch/71068/
State New
Headers show

Comments

Kai Tietz - Nov. 13, 2010, 6:41 p.m.
Hello,

I noticed a memory leak in add_output_files in lto-plugin.c file.

ChangeLog

2010-11-13  Kai Tietz

        * lto-plugin.c (add_output_files): Fix memory leak.

Tested for x86_64-w64-mingw32, i686-w64-mingw32, and i686-pc-cygwin.
Ok for apply?

Regards,
Kai
Diego Novillo - Nov. 13, 2010, 6:43 p.m.
On Sat, Nov 13, 2010 at 13:41, Kai Tietz <ktietz70@googlemail.com> wrote:

> 2010-11-13  Kai Tietz
>
>        * lto-plugin.c (add_output_files): Fix memory leak.

OK.


Diego.
Kai Tietz - Nov. 13, 2010, 6:49 p.m.
2010/11/13 Diego Novillo <dnovillo@google.com>:
> On Sat, Nov 13, 2010 at 13:41, Kai Tietz <ktietz70@googlemail.com> wrote:
>
>> 2010-11-13  Kai Tietz
>>
>>        * lto-plugin.c (add_output_files): Fix memory leak.
>
> OK.
>
>
> Diego.
>

Committed at revision 166718.

Thanks,
Kai

Patch

Index: lto-plugin.c
===================================================================
--- lto-plugin.c        (revision 166701)
+++ lto-plugin.c        (working copy)
@@ -461,7 +461,10 @@ 
       buf = s;
 cont:
       if (!fgets (buf, piece, f))
-       break;
+       {
+         free (s);
+         break;
+       }
       len = strlen (s);
       if (s[len - 1] != '\n')
        {