]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix index bounds check in Super_Delete functions and procedures
authorAleksandra Pasek <pasek@adacore.com>
Mon, 3 Mar 2025 20:09:25 +0000 (20:09 +0000)
committerMarc Poulhiès <dkm@gcc.gnu.org>
Thu, 3 Jul 2025 08:16:19 +0000 (10:16 +0200)
gcc/ada/ChangeLog:

* libgnat/a-strsup.adb (Super_Delete): Fix index check.
* libgnat/a-stwisu.adb (Super_Delete): Likewise.
* libgnat/a-stzsup.adb (Super_Delete): Likewise.

gcc/ada/libgnat/a-strsup.adb
gcc/ada/libgnat/a-stwisu.adb
gcc/ada/libgnat/a-stzsup.adb

index 8afde7185816da6188a22ed93dac02746b5a264a..3ac1a5ac724975b2fba8498a68d9cdcf2594ea87 100644 (file)
@@ -755,7 +755,7 @@ package body Ada.Strings.Superbounded with SPARK_Mode is
       if Num_Delete <= 0 then
          return Source;
 
-      elsif From - 1 > Slen then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then
@@ -784,7 +784,7 @@ package body Ada.Strings.Superbounded with SPARK_Mode is
       if Num_Delete <= 0 then
          return;
 
-      elsif From - 1 > Slen then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then
index e7e6b1f75c19ac6986062e61c405c525e76a1f36..28ae887cc5a9a96d2bbcd63c5350eaeaf382a5d1 100644 (file)
@@ -753,7 +753,7 @@ package body Ada.Strings.Wide_Superbounded is
       if Num_Delete <= 0 then
          return Source;
 
-      elsif From > Slen + 1 then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then
@@ -782,7 +782,7 @@ package body Ada.Strings.Wide_Superbounded is
       if Num_Delete <= 0 then
          return;
 
-      elsif From > Slen + 1 then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then
index fb1baf6c62cf56c9951b5659e106a6683a27e7db..5dcbadf3c030a035f845cad74d854221c44a905e 100644 (file)
@@ -754,7 +754,7 @@ package body Ada.Strings.Wide_Wide_Superbounded is
       if Num_Delete <= 0 then
          return Source;
 
-      elsif From > Slen + 1 then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then
@@ -783,7 +783,7 @@ package body Ada.Strings.Wide_Wide_Superbounded is
       if Num_Delete <= 0 then
          return;
 
-      elsif From > Slen + 1 then
+      elsif From > Slen then
          raise Ada.Strings.Index_Error;
 
       elsif Through >= Slen then