From patchwork Mon Aug 27 20:52:33 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 180279 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 12AA32C00D4 for ; Tue, 28 Aug 2012 06:53:01 +1000 (EST) Comment: DKIM? See http://www.dkim.org DKIM-Signature: v=1; a=rsa-sha1; c=relaxed/relaxed; d=gcc.gnu.org; s=default; x=1346705582; h=Comment: DomainKey-Signature:Received:Received:Received:Received: Message-ID:Date:From:User-Agent:MIME-Version:To:Subject: Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:Sender:Delivered-To; bh=sH3h1FH q2srpMUWAi6T+TsjUpnw=; b=GyhadP4q206c56ZIWkCiec8PjW0HnJkxfiv27xY YwZnTH19VJhohM26zKjpyPPSJHNXbmbqWQS5aP42mSuD4koVw9OccumgytBpMU9D AyCftqIe6BuFErTs0HspoQJt7YmQ2OD/yNVRiPEfZzi7ePgt5/Zuioq7IPwcVtBL KhFw= Comment: DomainKeys? See http://antispam.yahoo.com/domainkeys DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=default; d=gcc.gnu.org; h=Received:Received:X-SWARE-Spam-Status:X-Spam-Check-By:Received:Received:Message-ID:Date:From:User-Agent:MIME-Version:To:Subject:Content-Type:Mailing-List:Precedence:List-Id:List-Unsubscribe:List-Archive:List-Post:List-Help:Sender:Delivered-To; b=eDPC5shh7TeJEQREAm/7TmrEUNMwb9xt4JDHt0TKV3n2wIP8GEv/AtISivPyWD BoWn0XRr9WX6kFf4M3vK56N/hnqwkTr4kgg+n+JKcWBwRTRv0K1riUelPoCz2Wff u+jm8l/zVuR9QJ3Gw/cQ5GTebWwrxYkD9Ux2DCItUL7Fs=; Received: (qmail 14842 invoked by alias); 27 Aug 2012 20:52:52 -0000 Received: (qmail 14826 invoked by uid 22791); 27 Aug 2012 20:52:51 -0000 X-SWARE-Spam-Status: No, hits=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx02.qsc.de (HELO mx02.qsc.de) (213.148.130.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 27 Aug 2012 20:52:37 +0000 Received: from [192.168.178.22] (port-92-204-67-8.dynamic.qsc.de [92.204.67.8]) by mx02.qsc.de (Postfix) with ESMTP id E6DDA242F2; Mon, 27 Aug 2012 22:52:35 +0200 (CEST) Message-ID: <503BDE11.2040808@net-b.de> Date: Mon, 27 Aug 2012 22:52:33 +0200 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:14.0) Gecko/20120713 Thunderbird/14.0 MIME-Version: 1.0 To: gcc patches , gfortran Subject: [patch, Fortran, committed] Free temporary variables 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 Another obvious leakage fix: For "if( e1 == NULL || e2 == NULL)" one has to free the non-NULL expression (if there is one). Similarly, vector of type "tree *" has to be freed - we only need the elements of that vector. Build and tested on x86-64-linux. Committed as Rev. 190731 Tobias Index: gcc/fortran/ChangeLog =================================================================== --- gcc/fortran/ChangeLog (Revision 190730) +++ gcc/fortran/ChangeLog (Arbeitskopie) @@ -1,6 +1,13 @@ 2012-08-27 Tobias Burnus PR fortran/54384 + * resolve.c (gfc_resolve_character_operator): Free temporary + variables. + * trans-expr.c (gfc_conv_statement_function): Ditto. + +2012-08-27 Tobias Burnus + + PR fortran/54384 * dependency.c (check_section_vs_section): Use gfc_free_expr instead of free. * trans-intrinsic.c (conv_generic_with_optional_char_arg): Use Index: gcc/fortran/resolve.c =================================================================== --- gcc/fortran/resolve.c (Revision 190730) +++ gcc/fortran/resolve.c (Arbeitskopie) @@ -5593,7 +5593,12 @@ gfc_resolve_character_operator (gfc_expr *e) e->ts.u.cl = gfc_new_charlen (gfc_current_ns, NULL); if (!e1 || !e2) - return; + { + gfc_free_expr (e1); + gfc_free_expr (e2); + + return; + } e->ts.u.cl->length = gfc_add (e1, e2); e->ts.u.cl->length->ts.type = BT_INTEGER; Index: gcc/fortran/trans-expr.c =================================================================== --- gcc/fortran/trans-expr.c (Revision 190730) +++ gcc/fortran/trans-expr.c (Arbeitskopie) @@ -5080,6 +5080,7 @@ gfc_conv_statement_function (gfc_se * se, gfc_expr /* Restore the original variables. */ for (fargs = sym->formal, n = 0; fargs; fargs = fargs->next, n++) gfc_restore_sym (fargs->sym, &saved_vars[n]); + free (temp_vars); free (saved_vars); }