From patchwork Fri Oct 21 01:43:02 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jerry DeLisle X-Patchwork-Id: 684837 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]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3t0T3V2ps8z9s5g for ; Fri, 21 Oct 2016 12:43:33 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.b=E76yK6Wu; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; q=dns; s=default; b=CbYQVfzYdSQgsyDC mJ9TXUkmjh6vurdVmDRAc7udvuvZVEIxFK8ixk326Uv6QQOJK0UolojVUPT4/aMo aJqCdM14nVFH7FUAc4M65TlK5MKb/LXrGFe95FymLa2f/Phn4Xo5qjg63URgSnXc 0zOEI6hDpivG0oDPrwomDgeMFz0= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:to:cc :from:subject:message-id:date:mime-version:content-type :content-transfer-encoding; s=default; bh=U5ewKkwDw+5T+iKd1RmLnV PV5Lo=; b=E76yK6WunMV5rJsc3e1la5rptSMblrqlVx/s2J7UyWaMGn52QS+LBD HyxgzmUB+QWfVwzV3BwJZfZmgTsBMMXJ0SpGBke/07WMDO8jculjr2zQr6/9N+H9 tYu9XB9BQSl0AIvx5ROwQ23anzXEaD9NVco8zVdg62EyVzLCGWDnk= Received: (qmail 117951 invoked by alias); 21 Oct 2016 01:43:16 -0000 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 Received: (qmail 117933 invoked by uid 89); 21 Oct 2016 01:43:16 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE, RP_MATCHES_RCVD, SPF_PASS autolearn=ham version=3.3.2 spammy=sk:IOPARM_, sk:ioparm_, sk:finaliz, sk:1f46ca6 X-Spam-User: qpsmtpd, 2 recipients X-HELO: mtaout001-public.msg.strl.va.charter.net Received: from mtaout001-public.msg.strl.va.charter.net (HELO mtaout001-public.msg.strl.va.charter.net) (68.114.190.26) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Fri, 21 Oct 2016 01:43:05 +0000 Received: from impout002 ([68.114.189.17]) by mtaout001.msg.strl.va.charter.net (InterMail vM.9.00.023.01 201-2473-194) with ESMTP id <20161021014303.VLNF7355.mtaout001.msg.strl.va.charter.net@impout002>; Thu, 20 Oct 2016 20:43:03 -0500 Received: from amda8.localdomain ([96.41.215.23]) by impout002 with charter.net id y1j21t00A0Wrkg0011j22l; Thu, 20 Oct 2016 20:43:03 -0500 X-Authority-Analysis: v=2.1 cv=eLudjRZ1 c=1 sm=1 tr=0 a=salB9WdMPIDduBH7JsZfrA==:117 a=salB9WdMPIDduBH7JsZfrA==:17 a=L9H7d07YOLsA:10 a=9cW_t1CCXrUA:10 a=s5jvgZ67dGcA:10 a=IkcTkHD0fZMA:10 a=mDV3o1hIAAAA:8 a=2YYD7fIG6zsLrZdJKiEA:9 a=QEXdDO2ut3YA:10 a=_FVE-zBwftR9WsbkzFJk:22 X-Auth-id: anZkZWxpc2xlQGNoYXJ0ZXIubmV0 To: "fortran@gcc.gnu.org" Cc: GCC Patches From: Jerry DeLisle Subject: [COMMITTED] libgfortran Fix a few memory leaks Message-ID: <565e5ec8-f049-ce0b-0f40-7bed5ae9c684@charter.net> Date: Thu, 20 Oct 2016 18:43:02 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.4.0 MIME-Version: 1.0 While investigating PR70855 I found a few minor issues. Attached patch regression tested on x86-64-linux, M libgfortran/ChangeLog M libgfortran/io/transfer.c Committed r241392 2016-10-20 Jerry DeLisle * io/transfer.c (finalize_transfer): Free format data in child procedures. (st_read_done, st_write_done): Don't free format hash table. diff --git a/libgfortran/io/transfer.c b/libgfortran/io/transfer.c index 1f46ca64..0879ca7a 100644 --- a/libgfortran/io/transfer.c +++ b/libgfortran/io/transfer.c @@ -3783,7 +3783,14 @@ finalize_transfer (st_parameter_dt *dtp) } if (dtp->u.p.current_unit && (dtp->u.p.current_unit->child_dtio > 0)) - return; + { + if (cf & IOPARM_DT_HAS_FORMAT) + { + free (dtp->u.p.fmt); + free (dtp->format); + } + return; + } if ((dtp->common.flags & IOPARM_DT_HAS_SIZE) != 0) *dtp->size = dtp->u.p.current_unit->size_used; @@ -3972,7 +3979,6 @@ st_read_done (st_parameter_dt *dtp) { free (dtp->u.p.current_unit->filename); dtp->u.p.current_unit->filename = NULL; - free_format_hash_table (dtp->u.p.current_unit); free (dtp->u.p.current_unit->s); dtp->u.p.current_unit->s = NULL; if (dtp->u.p.current_unit->ls) @@ -4043,7 +4049,6 @@ st_write_done (st_parameter_dt *dtp) { free (dtp->u.p.current_unit->filename); dtp->u.p.current_unit->filename = NULL; - free_format_hash_table (dtp->u.p.current_unit); free (dtp->u.p.current_unit->s); dtp->u.p.current_unit->s = NULL; if (dtp->u.p.current_unit->ls)