aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMartin Sebor <msebor@redhat.com>2022-01-25 17:38:31 -0700
committerMartin Sebor <msebor@redhat.com>2022-01-25 17:38:31 -0700
commit7845064d2d5a50e347ee9f4b78ec5e6316190154 (patch)
tree4d23c5ecbdc9e6bc3754942d90756ccbb3e7a145
parent03ad86880f68f498ee04e9ea84cd4f0d14473970 (diff)
downloadglibc-7845064d2d5a50e347ee9f4b78ec5e6316190154.tar
glibc-7845064d2d5a50e347ee9f4b78ec5e6316190154.tar.gz
glibc-7845064d2d5a50e347ee9f4b78ec5e6316190154.tar.bz2
glibc-7845064d2d5a50e347ee9f4b78ec5e6316190154.zip
intl: Avoid -Wuse-after-free [BZ #26779]
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
-rw-r--r--intl/localealias.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/intl/localealias.c b/intl/localealias.c
index 3ae360f40d..b36092363a 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;
}