From patchwork Mon Nov 26 16:44:32 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 201730 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 8D98E2C0189 for ; Tue, 27 Nov 2012 03:45:11 +1100 (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=1354553112; 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=4QlHyKM 4VX7JPi+Ml2zpFd6a1rw=; b=qIlyKh7/3ivMUKtsnNeNsC6oMb9HsmhHHA6Eu7G 9TcZEeW1BKuuA5Z/4WSc+ae3BtL9Js5/vlPD4fK+eRRZiRP7UK6KyO9zqEamP2i7 7cO4yv3SzP+WakY/VcU1rtHZWW6/bt/gQCIQQrUecQRnMtPctaYxw88X0irJUYVA PCSE= 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=XuUV5lk8UQNLg1CEy6aZQjHGNPVNzljnVACWxjv/YNc50+gWKR85HAvE8zOsXF cbNoHUWnzS55pXMWVGNz9oKJrkp53Lmc0LmdFwAvhzYPWwE6+8FhM74k0N65Y6V9 iEa9TVXN43lUqZQhns8wHSSMxz3AdoO9O0QUg3WA8yeXw=; Received: (qmail 16042 invoked by alias); 26 Nov 2012 16:44:47 -0000 Received: (qmail 15965 invoked by uid 22791); 26 Nov 2012 16:44:45 -0000 X-SWARE-Spam-Status: No, hits=-2.1 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE X-Spam-Check-By: sourceware.org Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Mon, 26 Nov 2012 16:44:36 +0000 Received: from [192.168.178.25] (port-92-195-33-30.dynamic.qsc.de [92.195.33.30]) by mx01.qsc.de (Postfix) with ESMTP id 47B4A3CC93; Mon, 26 Nov 2012 17:44:33 +0100 (CET) Message-ID: <50B39C70.9010304@net-b.de> Date: Mon, 26 Nov 2012 17:44:32 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: gcc patches , gfortran , Jerry DeLisle Subject: [Patch, Fortran] PR5469 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 l_push_char allocates memory which is freed with free_line. However, currently, the memory is not always freed when calling generate_error. If one aborts, that's fine. However, generate_error can also set the iostat variable. Thus, one should ensure that the memory is always freed. I wouldn't mind if someone, who knows libgfortran/io better than I, could confirm that the patch is okay. I don't want too free memory which is later used. Build and regtested on x86-64-linux. OK for the trunk? Tobias PS: Test case see PR. (I don't think it makes sense to include it in the test suite.) PPS: I see the following failures when regtesting; the LTO and the realloc one I know, but I haven't see the reassoc_4.f before. It cannot be due to my patch and when I run it manually, it also works: FAIL: gfortran.dg/lto/pr45586 f_lto_pr45586_0.o-f_lto_pr45586_0.o link, -O0 -flto (internal compiler error) FAIL: gfortran.dg/realloc_on_assign_5.f03 -O0 execution test FAIL: gfortran.dg/reassoc_4.f -O scan-tree-dump-times reassoc1 "[0-9] \\* " 22 2012-11-26 Tobias Burnus PR fortran/5469 * io/list_read (parse_repeat, read_integer, read_character, parse_real, read_real, check_type, list_formatted_read_scalar, finish_list_read): Call list_free. diff --git a/libgfortran/io/list_read.c b/libgfortran/io/list_read.c index 403e719..49615b3 100644 --- a/libgfortran/io/list_read.c +++ b/libgfortran/io/list_read.c @@ -617,6 +617,7 @@ parse_repeat (st_parameter_dt *dtp) free_saved (dtp); if (c == EOF) { + free_line (dtp); hit_eof (dtp); return 1; } @@ -905,11 +906,14 @@ read_integer (st_parameter_dt *dtp, int length) free_saved (dtp); if (c == EOF) { + free_line (dtp); hit_eof (dtp); return; } else if (c != '\n') eat_line (dtp); + + free_line (dtp); snprintf (message, MSGLEN, "Bad integer for item %d in list input", dtp->u.p.item_count); generate_error (&dtp->common, LIBERROR_READ_VALUE, message); @@ -1078,7 +1082,6 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) unget_char (dtp, c); eat_separator (dtp); dtp->u.p.saved_type = BT_CHARACTER; - free_line (dtp); } else { @@ -1087,10 +1090,12 @@ read_character (st_parameter_dt *dtp, int length __attribute__ ((unused))) dtp->u.p.item_count); generate_error (&dtp->common, LIBERROR_READ_VALUE, message); } + free_line (dtp); return; eof: free_saved (dtp); + free_line (dtp); hit_eof (dtp); } @@ -1283,11 +1288,14 @@ parse_real (st_parameter_dt *dtp, void *buffer, int length) free_saved (dtp); if (c == EOF) { + free_line (dtp); hit_eof (dtp); return 1; } else if (c != '\n') eat_line (dtp); + + free_line (dtp); snprintf (message, MSGLEN, "Bad floating point number for item %d", dtp->u.p.item_count); generate_error (&dtp->common, LIBERROR_READ_VALUE, message); @@ -1387,11 +1395,14 @@ eol_4: free_saved (dtp); if (c == EOF) { + free_line (dtp); hit_eof (dtp); return; } else if (c != '\n') eat_line (dtp); + + free_line (dtp); snprintf (message, MSGLEN, "Bad complex value in item %d of list input", dtp->u.p.item_count); generate_error (&dtp->common, LIBERROR_READ_VALUE, message); @@ -1762,12 +1773,14 @@ read_real (st_parameter_dt *dtp, void * dest, int length) free_saved (dtp); if (c == EOF) { + free_line (dtp); hit_eof (dtp); return; } else if (c != '\n') eat_line (dtp); + free_line (dtp); snprintf (message, MSGLEN, "Bad real number in item %d of list input", dtp->u.p.item_count); generate_error (&dtp->common, LIBERROR_READ_VALUE, message); @@ -1784,6 +1797,7 @@ check_type (st_parameter_dt *dtp, bt type, int len) if (dtp->u.p.saved_type != BT_UNKNOWN && dtp->u.p.saved_type != type) { + free_line (dtp); snprintf (message, MSGLEN, "Read type %s where %s was expected for item %d", type_name (dtp->u.p.saved_type), type_name (type), dtp->u.p.item_count); @@ -1797,6 +1811,7 @@ check_type (st_parameter_dt *dtp, bt type, int len) if (dtp->u.p.saved_length != len) { + free_line (dtp); snprintf (message, MSGLEN, "Read kind %d %s where kind %d is required for item %d", dtp->u.p.saved_length, type_name (dtp->u.p.saved_type), len, @@ -1970,7 +1985,10 @@ list_formatted_read_scalar (st_parameter_dt *dtp, bt type, void *p, cleanup: if (err == LIBERROR_END) - hit_eof (dtp); + { + free_line (dtp); + hit_eof (dtp); + } return err; } @@ -2018,7 +2036,10 @@ finish_list_read (st_parameter_dt *dtp) err = eat_line (dtp); if (err == LIBERROR_END) - hit_eof (dtp); + { + free_line (dtp); + hit_eof (dtp); + } } /* NAMELIST INPUT