From 35260dd303a1f5c911310f87e7ddc3f1b580abbd Mon Sep 17 00:00:00 2001 From: Tonu Naks Date: Fri, 7 Feb 2025 12:55:30 +0000 Subject: [PATCH] ada: Add explicit null pointer check in C.Strings.Update gcc/ada/ChangeLog: * libgnat/i-cstrin.adb: null pointer check in Update --- gcc/ada/libgnat/i-cstrin.adb | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gcc/ada/libgnat/i-cstrin.adb b/gcc/ada/libgnat/i-cstrin.adb index 974ba3a0e8c..82795627a29 100644 --- a/gcc/ada/libgnat/i-cstrin.adb +++ b/gcc/ada/libgnat/i-cstrin.adb @@ -281,6 +281,11 @@ is Index : chars_ptr := Item + Offset; begin + -- Check for null pointer as mandated by the RM. + if Item = Null_Ptr then + raise Dereference_Error; + end if; + if Check and then Offset + Chars'Length > Strlen (Item) then raise Update_Error; end if; -- 2.47.2