intl: Avoid -Wuse-after-free [BZ #26779]

Reviewed-by: Carlos O'Donell <carlos@redhat.com>
This commit is contained in:
Martin Sebor 2022-01-25 17:38:31 -07:00
parent 03ad86880f
commit 7845064d2d
1 changed files with 11 additions and 1 deletions

View 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;
}