6ca6e8
commit d36f457870a807f6f29880a2f2bde5e9b761f00c
6ca6e8
Author: Martin Sebor <msebor@redhat.com>
6ca6e8
Date:   Tue Jan 25 17:38:31 2022 -0700
6ca6e8
6ca6e8
    intl: Avoid -Wuse-after-free [BZ #26779]
6ca6e8
    
6ca6e8
    Reviewed-by: Carlos O'Donell <carlos@redhat.com>
6ca6e8
    (cherry picked from commit 7845064d2d5a50e347ee9f4b78ec5e6316190154)
6ca6e8
6ca6e8
diff --git a/intl/localealias.c b/intl/localealias.c
6ca6e8
index 375af2b03153acce..28041f2a48f643fa 100644
6ca6e8
--- a/intl/localealias.c
6ca6e8
+++ b/intl/localealias.c
6ca6e8
@@ -318,7 +318,15 @@ read_alias_file (const char *fname, int fname_len)
6ca6e8
 
6ca6e8
 		  if (string_space_act + alias_len + value_len > string_space_max)
6ca6e8
 		    {
6ca6e8
-		      /* Increase size of memory pool.  */
6ca6e8
+#pragma GCC diagnostic push
6ca6e8
+
6ca6e8
+#if defined __GNUC__ && __GNUC__ >= 12
6ca6e8
+  /* Suppress the valid GCC 12 warning until the code below is changed
6ca6e8
+     to avoid using pointers to the reallocated block.  */
6ca6e8
+#  pragma GCC diagnostic ignored "-Wuse-after-free"
6ca6e8
+#endif
6ca6e8
+
6ca6e8
+		    /* Increase size of memory pool.  */
6ca6e8
 		      size_t new_size = (string_space_max
6ca6e8
 					 + (alias_len + value_len > 1024
6ca6e8
 					    ? alias_len + value_len : 1024));
6ca6e8
@@ -351,6 +359,8 @@ read_alias_file (const char *fname, int fname_len)
6ca6e8
 					   value, value_len);
6ca6e8
 		  string_space_act += value_len;
6ca6e8
 
6ca6e8
+#pragma GCC diagnostic pop
6ca6e8
+
6ca6e8
 		  ++nmap;
6ca6e8
 		  ++added;
6ca6e8
 		}