https://gcc.gnu.org/g:35260dd303a1f5c911310f87e7ddc3f1b580abbd

commit r16-1167-g35260dd303a1f5c911310f87e7ddc3f1b580abbd
Author: Tonu Naks <n...@adacore.com>
Date:   Fri Feb 7 12:55:30 2025 +0000

    ada: Add explicit null pointer check in C.Strings.Update
    
    gcc/ada/ChangeLog:
    
            * libgnat/i-cstrin.adb: null pointer check in Update

Diff:
---
 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 974ba3a0e8ca..82795627a290 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;

Reply via email to