]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix string indexing within GNAT.Calendar.Time_IO.Value
authorJustin Squirek <squirek@adacore.com>
Fri, 27 Oct 2023 00:08:07 +0000 (00:08 +0000)
committerMarc Poulhiès <poulhies@adacore.com>
Tue, 21 Nov 2023 09:57:42 +0000 (10:57 +0100)
The patch fixes an issue in the compiler whereby calls to
GNAT.Calendar.Time_IO.Value where the actual for formal String Date with
indexing starting at any value besides one would result in a spurious runtime
exception.

gcc/ada/

* libgnat/g-catiio.adb (Value): Modify conditionals to use 'Last
instead of 'Length

gcc/ada/libgnat/g-catiio.adb

index 42b86cce4a15115f047e48d72bf02d09e30fa233..d80e6fc1ca0c47aafc8f9d2608220c37dfeab1b6 100644 (file)
@@ -849,7 +849,7 @@ package body GNAT.Calendar.Time_IO is
       begin
          Advance_Digits (Num_Digits => 1);
 
-         while Index <= Date'Length and then Symbol in '0' .. '9' loop
+         while Index <= Date'Last and then Symbol in '0' .. '9' loop
             Advance;
          end loop;
 
@@ -1005,7 +1005,7 @@ package body GNAT.Calendar.Time_IO is
 
       --  Check for trailing characters
 
-      if Index /= Date'Length + 1 then
+      if Index /= Date'Last + 1 then
          raise Wrong_Syntax;
       end if;