[gcc r16-1167] ada: Add explicit null pointer check in C.Strings.Update
Marc Poulhies
dkm@gcc.gnu.org
Thu Jun 5 08:23:14 GMT 2025
https://gcc.gnu.org/g:35260dd303a1f5c911310f87e7ddc3f1b580abbd
commit r16-1167-g35260dd303a1f5c911310f87e7ddc3f1b580abbd
Author: Tonu Naks <naks@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;
More information about the Gcc-cvs
mailing list