From: Tonu Naks <n...@adacore.com>

gcc/ada/ChangeLog:

        * libgnat/i-cstrin.adb: null pointer check in Update

Tested on x86_64-pc-linux-gnu, committed on master.

---
 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.43.0

Reply via email to