]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Add explicit null pointer check in C.Strings.Update
authorTonu Naks <naks@adacore.com>
Fri, 7 Feb 2025 12:55:30 +0000 (12:55 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 5 Jun 2025 08:18:38 +0000 (10:18 +0200)
gcc/ada/ChangeLog:

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

gcc/ada/libgnat/i-cstrin.adb

index 974ba3a0e8ca33609daea9c0bda25482bb60103b..82795627a290b0494fdcbda80cea69b4b99e6a08 100644 (file)
@@ -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;