From: Weixie Cui <[email protected]>

---
 ld/ChangeLog | 4 ++++
 ld/pe-dll.c  | 9 ++++++---
 2 files changed, 10 insertions(+), 3 deletions(-)

diff --git a/ld/ChangeLog b/ld/ChangeLog
index ffac8a831f3..9b06e8437d7 100644
--- a/ld/ChangeLog
+++ b/ld/ChangeLog
@@ -1,3 +1,7 @@
+2025-03-08  Weixie Cui  <[email protected]>
+
+       * pe-dll.c (pe_dll_generate_def_file): Return early when fopen fails.
+
 2025-09-16  Rainer Orth  <[email protected]>
 
        * configure.tgt <powerpc*-*-solaris*>: Remove.
diff --git a/ld/pe-dll.c b/ld/pe-dll.c
index f43bd14896e..fd30312aa73 100644
--- a/ld/pe-dll.c
+++ b/ld/pe-dll.c
@@ -1879,9 +1879,12 @@ pe_dll_generate_def_file (const char 
*pe_out_def_filename)
   FILE *out = fopen (pe_out_def_filename, "w");
 
   if (out == NULL)
-    /* xgettext:c-format */
-    einfo (_("%P: can't open output def file %s\n"),
-          pe_out_def_filename);
+    {
+      /* xgettext:c-format */
+      einfo (_("%P: can't open output def file %s\n"),
+            pe_out_def_filename);
+      return;
+    }
 
   if (pe_def_file)
     {
-- 
2.39.5 (Apple Git-154)


Reply via email to