From patchwork Sun Apr 2 15:05:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 1764222 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=er4NgsnP; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PqHRF2wvLz1yY8 for ; Mon, 3 Apr 2023 01:06:17 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id B0BF53853D33 for ; Sun, 2 Apr 2023 15:06:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org B0BF53853D33 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680447974; bh=dUnZb84GUq/oUGD2VePbz9JabCxAwoAfVHWOISUsrnM=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=er4NgsnPU0tLs+SeW+Zi0fLYzILq+WzAUZqVKQv/6wwnHPv61jZ/L8NGMQEfvzEPu 02vnGQ0Qr0wuntny381rV995/2aQ+YZQCjqnYgfAqBwuAmuKtsYGkQkc6d56H5PhdB BCkTHnZW1fbJaJsNsmgOe9A2OHqVCKbcJQHPGGDw= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x52b.google.com (mail-ed1-x52b.google.com [IPv6:2a00:1450:4864:20::52b]) by sourceware.org (Postfix) with ESMTPS id 626813858C53; Sun, 2 Apr 2023 15:05:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 626813858C53 Received: by mail-ed1-x52b.google.com with SMTP id eg48so107761924edb.13; Sun, 02 Apr 2023 08:05:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680447940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=dUnZb84GUq/oUGD2VePbz9JabCxAwoAfVHWOISUsrnM=; b=DIigW6EAQr5MtrvglT+OpYJQRRowSmGo69H2tc+9lEyaV4d4mlVO6IWqaHZSxdv/Eb utoI+JjhjA6YVpXCJEEsbqhHf6ZzlyBT9OqSZaskYJ5XqbeA7mOrSN2EqZqrtXQJjo/M sWaXeYDnGFK+NnRpZ7J/A4g5Opm8hoOnW2gK+lFu42WyTL+7aMHeZ4V67jYyBhsRlL+K psGXV4rxDNL7/qBem1pbniBsC7afJWCVF78OPBAmg0H6L5I8O5VgzaKyilYfdWtaw4rG w2YOZK53FemNsc+HffOecOa60j3QHF4/2x16DEqHUMI+zuNtzfhRHfyZHaNsGhQfB62k xkbg== X-Gm-Message-State: AAQBX9fbjh4aLNfYuY+ZPtyLz2Tm01zSouZd6XHvnTgAkBIre6TMad2q 7K67Z9+BX80tpkyBOSspR856jL6b5rM= X-Google-Smtp-Source: AKy350Z3s0sIkYo0ORYxJbezChz+dgGkDoylKBZ5rlPoxOD6oUCAmn/rO9elENUltqbbULJ9zfHrnA== X-Received: by 2002:aa7:d313:0:b0:4f9:e6f1:5c7c with SMTP id p19-20020aa7d313000000b004f9e6f15c7cmr33610491edq.32.1680447940742; Sun, 02 Apr 2023 08:05:40 -0700 (PDT) Received: from nbbrfq ([2001:871:227:1e16:8ec:e883:b72a:18fd]) by smtp.gmail.com with ESMTPSA id m9-20020a50c189000000b004fd2aab4953sm3360051edf.45.2023.04.02.08.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 08:05:38 -0700 (PDT) Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1pizGz-000Ad0-1Q; Sun, 02 Apr 2023 17:05:37 +0200 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , Ian Lance Taylor Subject: [PATCH 1/3] go: Fix memory leak in Integer_expression Date: Sun, 2 Apr 2023 17:05:13 +0200 Message-Id: <20230402150515.40826-2-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Bernhard Reutner-Fischer Cc: Ian Lance Taylor gcc/go/ChangeLog: * gofrontend/expressions.cc (Integer_expression::do_import): Fix memory leak. --- gcc/go/gofrontend/expressions.cc | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/go/gofrontend/expressions.cc b/gcc/go/gofrontend/expressions.cc index 4ac55af7433..93f5d5dc52b 100644 --- a/gcc/go/gofrontend/expressions.cc +++ b/gcc/go/gofrontend/expressions.cc @@ -2728,6 +2728,7 @@ Integer_expression::do_import(Import_expression* imp, Location loc) { go_error_at(imp->location(), "bad number in import data: %qs", real_str.c_str()); + mpfr_clear (real); return Expression::make_error(loc); } } @@ -2743,6 +2744,8 @@ Integer_expression::do_import(Import_expression* imp, Location loc) { go_error_at(imp->location(), "bad number in import data: %qs", imag_str.c_str()); + mpfr_clear (imag); + mpfr_clear (real); return Expression::make_error(loc); } mpc_t cval; @@ -2766,6 +2769,7 @@ Integer_expression::do_import(Import_expression* imp, Location loc) { go_error_at(imp->location(), "bad number in import data: %qs", num.c_str()); + mpz_clear (val); return Expression::make_error(loc); } Expression* ret; @@ -2783,6 +2787,7 @@ Integer_expression::do_import(Import_expression* imp, Location loc) { go_error_at(imp->location(), "bad number in import data: %qs", num.c_str()); + mpfr_clear (val); return Expression::make_error(loc); } Expression* ret = Expression::make_float(&val, NULL, loc); From patchwork Sun Apr 2 15:05:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 1764223 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=yz3OIfoD; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PqHS56st0z1yY8 for ; Mon, 3 Apr 2023 01:07:01 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id D9E9B385B519 for ; Sun, 2 Apr 2023 15:06:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org D9E9B385B519 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680448019; bh=S5Td04uYYTvHptqbR1rRss3IeqGirYjgywGM8cdKzNk=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=yz3OIfoDXd57Rp7YDIDRZcWeQ98ZoeSspk5GnDTdUeb8O0ZoFv2ZVK4AdxyCPPYwT Ng7IUCP2XHRG5i5fYp4RgZaZGTvcrGisbaC1F0WSn3G6W3yvv3ENa+lbZx2MlkRnik 3qKuOFgnFJeUB4E7nsqgTPFYSmXWUtn1NGkoUmQI= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x533.google.com (mail-ed1-x533.google.com [IPv6:2a00:1450:4864:20::533]) by sourceware.org (Postfix) with ESMTPS id F04013858C52; Sun, 2 Apr 2023 15:05:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org F04013858C52 Received: by mail-ed1-x533.google.com with SMTP id y4so107931051edo.2; Sun, 02 Apr 2023 08:05:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680447940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=S5Td04uYYTvHptqbR1rRss3IeqGirYjgywGM8cdKzNk=; b=sd5LBQiSaa3P+XrFObrduyVHe7kxirezNtaXrFS3xY7wEtCoouVkYHu5OsLE2eWOAX NQ9ImYJLsvQ/LwAGMk5iyZRxy15WJzsX6OO5QG1uvc2foW0OtVLaIPIOR6QhyZw4WcRc W4F6Ei/f4jkAaQwx1hlDKXcVJCRJjA19CgLmC+M2QSDH879UaBpBnnONL4eZd/gtgTu/ DScc7uBDZGVI8CwJACc+Jdb5gceNokER9qYlEzyYUbBG8TXslNcknuuOqyB2v4TWeC57 Bb+p0tI9zB9LYw9HPSMDS7UC4cZV6IG7dmGQ7H0luAnFQ8vq5XSOkicZ8mLs0ogxOWKm nkDA== X-Gm-Message-State: AAQBX9fnRPtkCeu+wIUn2N2EGOCnOomiqgYEnxRIvxaGcDQjeWsfZ7ol UbSRMWEUNmppiI0wgKsUbmZ+KWqe9v8= X-Google-Smtp-Source: AKy350YsiSUf59DnL0+XD3XpKM3OOovvYbT4w39ByUf8bd8IC8fVKL05kQWlrFyD8oJvlIf+nkYBWw== X-Received: by 2002:a17:906:1e08:b0:93b:d1ee:5f41 with SMTP id g8-20020a1709061e0800b0093bd1ee5f41mr33805693ejj.31.1680447940308; Sun, 02 Apr 2023 08:05:40 -0700 (PDT) Received: from nbbrfq ([2001:871:227:1e16:8ec:e883:b72a:18fd]) by smtp.gmail.com with ESMTPSA id t28-20020a50ab5c000000b005024faae65esm3366788edc.10.2023.04.02.08.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 08:05:38 -0700 (PDT) Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1pizGz-000Ad3-1a; Sun, 02 Apr 2023 17:05:37 +0200 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , Arthur Cohen , Philip Herron Subject: [PATCH 2/3] rust: Fix memory leak in compile_{integer,float}_literal Date: Sun, 2 Apr 2023 17:05:14 +0200 Message-Id: <20230402150515.40826-3-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-10.0 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Bernhard Reutner-Fischer Cc: Arthur Cohen Cc: Philip Herron gcc/rust/ChangeLog: * backend/rust-compile-expr.cc (CompileExpr::compile_integer_literal): (CompileExpr::compile_float_literal): Fix memory leak. --- gcc/rust/backend/rust-compile-expr.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/rust/backend/rust-compile-expr.cc b/gcc/rust/backend/rust-compile-expr.cc index 436fc924a13..82078b81953 100644 --- a/gcc/rust/backend/rust-compile-expr.cc +++ b/gcc/rust/backend/rust-compile-expr.cc @@ -2119,6 +2119,7 @@ CompileExpr::compile_integer_literal (const HIR::LiteralExpr &expr, if (mpz_init_set_str (ival, literal_value.as_string ().c_str (), 10) != 0) { rust_error_at (expr.get_locus (), "bad number in literal"); + mpz_clear (ival); return error_mark_node; } @@ -2133,6 +2134,9 @@ CompileExpr::compile_integer_literal (const HIR::LiteralExpr &expr, rust_error_at (expr.get_locus (), "integer overflows the respective type %<%s%>", tyty->get_name ().c_str ()); + mpz_clear (type_min); + mpz_clear (type_max); + mpz_clear (ival); return error_mark_node; } @@ -2158,6 +2162,7 @@ CompileExpr::compile_float_literal (const HIR::LiteralExpr &expr, != 0) { rust_error_at (expr.get_locus (), "bad number in literal"); + mpfr_clear (fval); return error_mark_node; } @@ -2179,9 +2184,11 @@ CompileExpr::compile_float_literal (const HIR::LiteralExpr &expr, rust_error_at (expr.get_locus (), "decimal overflows the respective type %<%s%>", tyty->get_name ().c_str ()); + mpfr_clear (fval); return error_mark_node; } + mpfr_clear (fval); return real_value; } From patchwork Sun Apr 2 15:05:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bernhard Reutner-Fischer X-Patchwork-Id: 1764220 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=8.43.85.97; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=iAi5vx5h; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [8.43.85.97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4PqHR25r0Kz1yY8 for ; Mon, 3 Apr 2023 01:06:05 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 40F62385800A for ; Sun, 2 Apr 2023 15:06:02 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 40F62385800A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1680447962; bh=4ddGE+cYu1aKp+XvaWm+vBDEUggW6gNWux7egmyAEF8=; h=To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From:Reply-To:From; b=iAi5vx5hpraMXNGBPP8lLKB0nmWO60Ahba4SIZMveze+LzFQrnUqRHna5eTZN9Uxs YS3EIPpXktxHv/bX+qQu2aA3IY/8OxXhnQsMlMCa3mFgex0UB2hC0Zw/c/gHU5hMsm Ah4OXflQwihfBx7eIZv4fpg9wbZU15xnojI3c+ZA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from mail-ed1-x531.google.com (mail-ed1-x531.google.com [IPv6:2a00:1450:4864:20::531]) by sourceware.org (Postfix) with ESMTPS id 90AA73858C50; Sun, 2 Apr 2023 15:05:41 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 90AA73858C50 Received: by mail-ed1-x531.google.com with SMTP id h8so107880167ede.8; Sun, 02 Apr 2023 08:05:41 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680447940; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4ddGE+cYu1aKp+XvaWm+vBDEUggW6gNWux7egmyAEF8=; b=ERyKAru0QILGYILn2g/li6oF8dJJTqY2dMxNSUAiOMjokfGQiJg3dzie5kq5sTYkLL Wbk4893cMsdEufs4M8NNuWVuFRWpqHBfk2exin5zY1opZ9MhoajSoUHwx38exljEn440 7klAygdvusI037nYX8aWTDE1kQLEnTkiUbHlO1X7rIzMFFtkuvSsfwpTe9Oc9iS89cc2 0xxi9jvZvNaRW6P1H7Y37TPfDy3ijSa6p3m8HtNQZWLpbP3NPyixnAvpsh+yQl2mCWKo gr80ZP6Ka1V5wnOHMB6oRSBKCPeQwjFwk4/mtom0ZH3/i71D1VsjKa3qNgH70Kj85BhL SmYg== X-Gm-Message-State: AAQBX9drPPfzF4mw6l3yNdUm5iVW/xQhvDsgN7n/QgWG08Pa3vtA3jDU SevPj7TsYfSs2E1n2L+FDHaZY/D567c= X-Google-Smtp-Source: AKy350ahVMbCNY2Kzye3XGl/GTdiVilY2dzxyOl0o7CKovDOGKigoM7g3Ta3UshUj7oKa6qThCkXcA== X-Received: by 2002:a17:906:9618:b0:884:3174:119d with SMTP id s24-20020a170906961800b008843174119dmr34742793ejx.14.1680447939742; Sun, 02 Apr 2023 08:05:39 -0700 (PDT) Received: from nbbrfq ([2001:871:227:1e16:8ec:e883:b72a:18fd]) by smtp.gmail.com with ESMTPSA id u13-20020a1709063b8d00b0093e261cc8bcsm3326752ejf.58.2023.04.02.08.05.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 02 Apr 2023 08:05:38 -0700 (PDT) Received: from b by nbbrfq with local (Exim 4.96) (envelope-from ) id 1pizGz-000Ad8-1f; Sun, 02 Apr 2023 17:05:37 +0200 To: gcc-patches@gcc.gnu.org Cc: Bernhard Reutner-Fischer , fortran@gcc.gnu.org Subject: [PATCH 3/3] Fortran: Fix mpz and mpfr memory leaks Date: Sun, 2 Apr 2023 17:05:15 +0200 Message-Id: <20230402150515.40826-4-rep.dot.nop@gmail.com> X-Mailer: git-send-email 2.40.0 In-Reply-To: References: MIME-Version: 1.0 X-Spam-Status: No, score=-9.7 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, FREEMAIL_FROM, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Bernhard Reutner-Fischer via Gcc-patches From: Bernhard Reutner-Fischer Reply-To: Bernhard Reutner-Fischer Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" From: Bernhard Reutner-Fischer Cc: fortran@gcc.gnu.org gcc/fortran/ChangeLog: * array.cc (gfc_ref_dimen_size): Free mpz memory before ICEing. * expr.cc (find_array_section): Fix mpz memory leak. * simplify.cc (gfc_simplify_reshape): Fix mpz memory leaks in error paths. (gfc_simplify_set_exponent): Fix mpfr memory leak. --- gcc/fortran/array.cc | 3 +++ gcc/fortran/expr.cc | 8 ++++---- gcc/fortran/simplify.cc | 7 ++++++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/gcc/fortran/array.cc b/gcc/fortran/array.cc index be5eb8b6a0f..8b1e816a859 100644 --- a/gcc/fortran/array.cc +++ b/gcc/fortran/array.cc @@ -2541,6 +2541,9 @@ gfc_ref_dimen_size (gfc_array_ref *ar, int dimen, mpz_t *result, mpz_t *end) return t; default: + mpz_clear (lower); + mpz_clear (stride); + mpz_clear (upper); gfc_internal_error ("gfc_ref_dimen_size(): Bad dimen_type"); } diff --git a/gcc/fortran/expr.cc b/gcc/fortran/expr.cc index 7fb33f81788..b4736804eda 100644 --- a/gcc/fortran/expr.cc +++ b/gcc/fortran/expr.cc @@ -1539,6 +1539,7 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) mpz_init_set_ui (delta_mpz, one); mpz_init_set_ui (nelts, one); mpz_init (tmp_mpz); + mpz_init (ptr); /* Do the initialization now, so that we can cleanup without keeping track of where we were. */ @@ -1682,7 +1683,6 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) mpz_mul (delta_mpz, delta_mpz, tmp_mpz); } - mpz_init (ptr); cons = gfc_constructor_first (base); /* Now clock through the array reference, calculating the index in @@ -1735,7 +1735,8 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) "at %L requires an increase of the allowed %d " "upper limit. See %<-fmax-array-constructor%> " "option", &expr->where, flag_max_array_constructor); - return false; + t = false; + goto cleanup; } cons = gfc_constructor_lookup (base, limit); @@ -1750,8 +1751,6 @@ find_array_section (gfc_expr *expr, gfc_ref *ref) gfc_copy_expr (cons->expr), NULL); } - mpz_clear (ptr); - cleanup: mpz_clear (delta_mpz); @@ -1765,6 +1764,7 @@ cleanup: mpz_clear (ctr[d]); mpz_clear (stride[d]); } + mpz_clear (ptr); gfc_constructor_free (base); return t; } diff --git a/gcc/fortran/simplify.cc b/gcc/fortran/simplify.cc index ecf0e3558df..d1f06335e79 100644 --- a/gcc/fortran/simplify.cc +++ b/gcc/fortran/simplify.cc @@ -6866,6 +6866,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, gfc_error ("The SHAPE array for the RESHAPE intrinsic at %L has a " "negative value %d for dimension %d", &shape_exp->where, shape[rank], rank+1); + mpz_clear (index); return &gfc_bad_expr; } @@ -6889,6 +6890,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, { gfc_error ("Shapes of ORDER at %L and SHAPE at %L are different", &order_exp->where, &shape_exp->where); + mpz_clear (index); return &gfc_bad_expr; } @@ -6902,6 +6904,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, { gfc_error ("Sizes of ORDER at %L and SHAPE at %L are different", &order_exp->where, &shape_exp->where); + mpz_clear (index); return &gfc_bad_expr; } @@ -6918,6 +6921,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, "in the range [1, ..., %d] for the RESHAPE intrinsic " "near %L", order[i], &order_exp->where, rank, &shape_exp->where); + mpz_clear (index); return &gfc_bad_expr; } @@ -6926,6 +6930,7 @@ gfc_simplify_reshape (gfc_expr *source, gfc_expr *shape_exp, { gfc_error ("ORDER at %L is not a permutation of the size of " "SHAPE at %L", &order_exp->where, &shape_exp->where); + mpz_clear (index); return &gfc_bad_expr; } x[order[i]] = 1; @@ -7408,7 +7413,7 @@ gfc_simplify_set_exponent (gfc_expr *x, gfc_expr *i) exp2 = (unsigned long) mpz_get_d (i->value.integer); mpfr_mul_2exp (result->value.real, frac, exp2, GFC_RND_MODE); - mpfr_clears (absv, log2, pow2, frac, NULL); + mpfr_clears (exp, absv, log2, pow2, frac, NULL); return range_check (result, "SET_EXPONENT"); }