From patchwork Sat Nov 13 18:41:13 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kai Tietz X-Patchwork-Id: 71068 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) by ozlabs.org (Postfix) with SMTP id AAE85B7113 for ; Sun, 14 Nov 2010 05:41:56 +1100 (EST) Received: (qmail 30926 invoked by alias); 13 Nov 2010 18:41:55 -0000 Received: (qmail 30918 invoked by uid 22791); 13 Nov 2010 18:41:54 -0000 X-SWARE-Spam-Status: No, hits=-0.8 required=5.0 tests=AWL, BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mail-qy0-f182.google.com (HELO mail-qy0-f182.google.com) (209.85.216.182) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 13 Nov 2010 18:41:15 +0000 Received: by qyk34 with SMTP id 34so647611qyk.20 for ; Sat, 13 Nov 2010 10:41:13 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.96.17 with SMTP id f17mr3305065qcn.142.1289673673623; Sat, 13 Nov 2010 10:41:13 -0800 (PST) Received: by 10.229.85.195 with HTTP; Sat, 13 Nov 2010 10:41:13 -0800 (PST) Date: Sat, 13 Nov 2010 19:41:13 +0100 Message-ID: Subject: {patch lto-plugin]: Fix memory leak From: Kai Tietz To: GCC Patches Cc: ccoutant@google.com X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org 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 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') {