diff options
author | Justin Squirek <squirek@adacore.com> | 2023-10-27 00:08:07 +0000 |
---|---|---|
committer | Marc Poulhiès <poulhies@adacore.com> | 2023-11-21 10:57:42 +0100 |
commit | 5c7854b28f56634cc3a8afb7889d1a76883a0cf3 (patch) | |
tree | bb731b00900e43a739f9ca2a27a3ea449ea716d8 | |
parent | 5ee80f712883981fde26976bb4f9e157e105944c (diff) | |
download | gcc-5c7854b28f56634cc3a8afb7889d1a76883a0cf3.zip gcc-5c7854b28f56634cc3a8afb7889d1a76883a0cf3.tar.gz gcc-5c7854b28f56634cc3a8afb7889d1a76883a0cf3.tar.bz2 |
ada: Fix string indexing within GNAT.Calendar.Time_IO.Value
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
-rw-r--r-- | gcc/ada/libgnat/g-catiio.adb | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/gcc/ada/libgnat/g-catiio.adb b/gcc/ada/libgnat/g-catiio.adb index 42b86cc..d80e6fc 100644 --- a/gcc/ada/libgnat/g-catiio.adb +++ b/gcc/ada/libgnat/g-catiio.adb @@ -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; |