From df3ca5a38ec2bdf53f5f42abb1a4b376ba414302 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Wed, 27 Sep 2006 11:14:59 +0000 Subject: [PATCH] * output-file.c (output_file_close): Prevent an infinite loop reporting that stdoutput could not be closed. --- gas/ChangeLog | 5 +++++ gas/output-file.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/gas/ChangeLog b/gas/ChangeLog index 6e72db5247d..4d49d9b89ce 100644 --- a/gas/ChangeLog +++ b/gas/ChangeLog @@ -1,3 +1,8 @@ +2006-09-27 Nick Clifton + + * output-file.c (output_file_close): Prevent an infinite loop + reporting that stdoutput could not be closed. + 2006-09-26 Mark Shinwell Joseph Myers Ian Lance Taylor diff --git a/gas/output-file.c b/gas/output-file.c index dfbef1f24d3..9603dc4f38a 100644 --- a/gas/output-file.c +++ b/gas/output-file.c @@ -53,9 +53,19 @@ output_file_create (char *name) void output_file_close (char *filename) { + bfd_boolean res; + + if (stdoutput == NULL) + return; + /* Close the bfd. */ - if (!bfd_close (stdoutput)) + res = bfd_close (stdoutput); + + /* Prevent an infinite loop - if the close failed we will call as_fatal + which will call xexit() which may call this function again... */ + stdoutput = NULL; + + if (! res) as_fatal (_("can't close %s: %s"), filename, bfd_errmsg (bfd_get_error ())); - stdoutput = NULL; /* Trust nobody! */ } -- 2.30.2