]> git.ipfire.org Git - thirdparty/gettext.git/commitdiff
intl: Fix an ISO C undefined behaviour.
authorBruno Haible <bruno@clisp.org>
Wed, 8 Apr 2026 22:59:08 +0000 (00:59 +0200)
committerBruno Haible <bruno@clisp.org>
Wed, 8 Apr 2026 22:59:08 +0000 (00:59 +0200)
ISO C 23 ยง 6.5.7.(10) has requirements for pointer subtraction.

Reported by <pizlonator> in https://github.com/pizlonator/fil-c/.

* gettext-runtime/intl/localealias.c (read_alias_file): Avoid invalid pointer
subtraction.

gettext-runtime/intl/localealias.c

index ff0f3f5042108bf61a9683c3c9bd485d23f974bb..7e0d4e7b56bab13bccb248ef038aef0a15b9658f 100644 (file)
@@ -375,8 +375,10 @@ read_alias_file (const char *fname, int fname_len)
 
                        for (i = 0; i < nmap; i++)
                          {
-                           map[i].alias += new_pool - string_space;
-                           map[i].value += new_pool - string_space;
+                           map[i].alias =
+                             new_pool + (map[i].alias - string_space);
+                           map[i].value =
+                             new_pool + (map[i].value - string_space);
                          }
                      }