From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2178) id 4B6163858D35; Thu, 12 Jan 2023 06:21:16 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4B6163858D35 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sourceware.org; s=default; t=1673504476; bh=6zO0FRQYHe7Q0FZGJJrw2MxfQ28b9s/4qNl6MRd+NoU=; h=From:To:Subject:Date:From; b=Ql3LEBfcXQSXo91dgxESsNWULlCH3on6PSD/j3MpK+h+/v1zvpCAoLyhv/Yhkeoer 7PXwbZ1TY8LQ4d6ECS9DxfZMeUTobyH4VeCQaLwNzmHpukakZ1p8HEm5w9c1u0keNm Iu7Z94wUMHMpeKVVrTIwELzpQo2W210PZs7ktPR0= Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Florian Weimer To: glibc-cvs@sourceware.org Subject: [glibc/release/2.34/master] intl: Avoid -Wuse-after-free [BZ #26779] X-Act-Checkin: glibc X-Git-Author: Martin Sebor X-Git-Refname: refs/heads/release/2.34/master X-Git-Oldrev: bbe4bbb6e8997b5ff9843bd3f32ac77dbaec7284 X-Git-Newrev: d36f457870a807f6f29880a2f2bde5e9b761f00c Message-Id: <20230112062116.4B6163858D35@sourceware.org> Date: Thu, 12 Jan 2023 06:21:16 +0000 (GMT) List-Id: https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=d36f457870a807f6f29880a2f2bde5e9b761f00c commit d36f457870a807f6f29880a2f2bde5e9b761f00c Author: Martin Sebor Date: Tue Jan 25 17:38:31 2022 -0700 intl: Avoid -Wuse-after-free [BZ #26779] Reviewed-by: Carlos O'Donell (cherry picked from commit 7845064d2d5a50e347ee9f4b78ec5e6316190154) Diff: --- intl/localealias.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/intl/localealias.c b/intl/localealias.c index 375af2b031..28041f2a48 100644 --- a/intl/localealias.c +++ b/intl/localealias.c @@ -318,7 +318,15 @@ read_alias_file (const char *fname, int fname_len) if (string_space_act + alias_len + value_len > string_space_max) { - /* Increase size of memory pool. */ +#pragma GCC diagnostic push + +#if defined __GNUC__ && __GNUC__ >= 12 + /* Suppress the valid GCC 12 warning until the code below is changed + to avoid using pointers to the reallocated block. */ +# pragma GCC diagnostic ignored "-Wuse-after-free" +#endif + + /* Increase size of memory pool. */ size_t new_size = (string_space_max + (alias_len + value_len > 1024 ? alias_len + value_len : 1024)); @@ -351,6 +359,8 @@ read_alias_file (const char *fname, int fname_len) value, value_len); string_space_act += value_len; +#pragma GCC diagnostic pop + ++nmap; ++added; }