]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
intl: Avoid -Wuse-after-free [BZ #26779]
authorMartin Sebor <msebor@redhat.com>
Wed, 26 Jan 2022 00:38:31 +0000 (17:38 -0700)
committerFlorian Weimer <fweimer@redhat.com>
Wed, 11 Jan 2023 12:29:41 +0000 (13:29 +0100)
Reviewed-by: Carlos O'Donell <carlos@redhat.com>
(cherry picked from commit 7845064d2d5a50e347ee9f4b78ec5e6316190154)

intl/localealias.c

index 375af2b03153acce033bc7dea621a6da703816f3..28041f2a48f643fa8b2afb1759dd0a05e8584910 100644 (file)
@@ -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;
                }