]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ada: Fix crash in GNATbind during error reporting
authorEric Botcazou <ebotcazou@adacore.com>
Wed, 5 Jun 2024 08:40:35 +0000 (10:40 +0200)
committerMarc Poulhiès <poulhies@adacore.com>
Fri, 21 Jun 2024 08:34:21 +0000 (10:34 +0200)
This is the minimal fix to avoid the crash.

gcc/ada/

* bcheck.adb (Check_Consistency_Of_Sdep): Guard against path to ALI
file not found.

gcc/ada/bcheck.adb

index 56a417cc517607ed3a04c8631b3a850d72d0a7a2..64a6734a330c3d4ab49cc93731b728687d5d85f9 100644 (file)
@@ -162,10 +162,14 @@ package body Bcheck is
             end if;
 
          else
-            ALI_Path_Id :=
-              Osint.Full_Lib_File_Name (A.Afile);
+            ALI_Path_Id := Osint.Full_Lib_File_Name (A.Afile);
+
+            --  Guard against Find_File not finding (again) the file because
+            --  Primary_Directory has been clobbered in between.
 
-            if Osint.Is_Readonly_Library (ALI_Path_Id) then
+            if Present (ALI_Path_Id)
+              and then Osint.Is_Readonly_Library (ALI_Path_Id)
+            then
                if Tolerate_Consistency_Errors then
                   Error_Msg ("?{ should be recompiled");
                   Error_Msg_File_1 := ALI_Path_Id;