[gcc r15-1523] ada: Fix crash in GNATbind during error reporting

Marc Poulhi?s dkm@gcc.gnu.org
Fri Jun 21 08:38:31 GMT 2024


https://gcc.gnu.org/g:728c1454c2b405543687d80238d8af4f12bcdca2

commit r15-1523-g728c1454c2b405543687d80238d8af4f12bcdca2
Author: Eric Botcazou <ebotcazou@adacore.com>
Date:   Wed Jun 5 10:40:35 2024 +0200

    ada: Fix crash in GNATbind during error reporting
    
    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.

Diff:
---
 gcc/ada/bcheck.adb | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)

diff --git a/gcc/ada/bcheck.adb b/gcc/ada/bcheck.adb
index 56a417cc5176..64a6734a330c 100644
--- a/gcc/ada/bcheck.adb
+++ b/gcc/ada/bcheck.adb
@@ -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;


More information about the Gcc-cvs mailing list