[Ada] Fix potential Constraint_Error if Library_Version is too long
authorArnaud Charlet <charlet@adacore.com>
Tue, 31 Jul 2018 09:56:53 +0000 (09:56 +0000)
committerPierre-Marie de Rodat <pmderodat@gcc.gnu.org>
Tue, 31 Jul 2018 09:56:53 +0000 (09:56 +0000)
2018-07-31  Arnaud Charlet  <charlet@adacore.com>

gcc/ada/

* gnatlink.adb: Fix potential Constraint_Error if
Library_Version is too long.

From-SVN: r263107

gcc/ada/ChangeLog
gcc/ada/gnatlink.adb

index 92ec7513bd58b3caa4f72f157fcc8350899ad104..ba9599e2980a076a56902e15a80795ba242f97d5 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-31  Arnaud Charlet  <charlet@adacore.com>
+
+       * gnatlink.adb: Fix potential Constraint_Error if
+       Library_Version is too long.
+
 2018-07-31  Arnaud Charlet  <charlet@adacore.com>
 
        * sem_elab.adb: Remove duplicate condition detected by CodePeer.
index f712a7abb6c546c286652242cb258cb5b5756e77..16981b88d5c0c74770b962466901c1aa5c1277d2 100644 (file)
@@ -1102,8 +1102,10 @@ procedure Gnatlink is
                   --  We will be looking for the static version of the library
                   --  as it is in the same directory as the shared version.
 
-                  if Next_Line (Nlast - Library_Version'Length + 1 .. Nlast) =
-                       Library_Version
+                  if Nlast >= Library_Version'Length
+                    and then Next_Line
+                      (Nlast - Library_Version'Length + 1 .. Nlast)
+                        = Library_Version
                   then
                      --  Set Last to point to last character before the
                      --  library version.