From: Joffrey Huguet Date: Thu, 12 May 2022 09:53:54 +0000 (+0200) Subject: [Ada] Fix preconditions of Interfaces.C.Strings X-Git-Tag: basepoints/gcc-14~6269 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=cfd2262668862167cbe102ffbe87f127599be7a8;p=thirdparty%2Fgcc.git [Ada] Fix preconditions of Interfaces.C.Strings Preconditions of Update procedures were always true when Offset was 0. The changes enable to protect from Update_Error when Offset is 0. gcc/ada/ * libgnat/i-cstrin.ads (Update): Update precondition. --- diff --git a/gcc/ada/libgnat/i-cstrin.ads b/gcc/ada/libgnat/i-cstrin.ads index faad7a0b73b..12fa3012ff0 100644 --- a/gcc/ada/libgnat/i-cstrin.ads +++ b/gcc/ada/libgnat/i-cstrin.ads @@ -120,7 +120,10 @@ is with Pre => Item /= Null_Ptr - and then (if Check then Offset <= Strlen (Item) - Chars'Length), + and then + (if Check then + Strlen (Item) <= size_t'Last - Offset + and then Strlen (Item) + Offset <= Chars'Length), Global => (In_Out => C_Memory); procedure Update @@ -131,7 +134,10 @@ is with Pre => Item /= Null_Ptr - and then (if Check then Offset <= Strlen (Item) - Str'Length), + and then + (if Check then + Strlen (Item) <= size_t'Last - Offset + and then Strlen (Item) + Offset <= Str'Length), Global => (In_Out => C_Memory); Update_Error : exception;