This is the mail archive of the binutils@sourceware.org mailing list for the binutils project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Prevent an inifite loop reporting that stdoutput cannot be closed


Hi Guys,

  I am checking in the patch below to prevent an infinite loop that I
  ran across in the assembler.  If for some reason the
  output_file_close() function cannot close the stdoutput bfd it will
  call as_fatal() with an error message.  Unfortunately as_fatal()
  will call xexit() which will call the functions registered with
  xatexit() which includes output_file_close(), and so the assembler
  will loop forever, complaining about being unable to close the
  output file.

Cheers
  Nick

gas/ChangeLog
2006-09-27  Nick Clifton  <nickc@redhat.com>

	* output-file.c (output_file_close): Prevent an infinite loop
	reporting that stdoutput could not be closed.

Index: gas/output-file.c
===================================================================
RCS file: /cvs/src/src/gas/output-file.c,v
retrieving revision 1.14
diff -c -3 -p -r1.14 output-file.c
*** gas/output-file.c	22 Sep 2006 11:35:13 -0000	1.14
--- gas/output-file.c	27 Sep 2006 11:13:20 -0000
*************** output_file_create (char *name)
*** 53,61 ****
  void
  output_file_close (char *filename)
  {
    /* Close the bfd.  */
!   if (!bfd_close (stdoutput))
      as_fatal (_("can't close %s: %s"), filename,
  	      bfd_errmsg (bfd_get_error ()));
-   stdoutput = NULL;		/* Trust nobody!  */
  }
--- 53,71 ----
  void
  output_file_close (char *filename)
  {
+   bfd_boolean res;
+ 
+   if (stdoutput == NULL)
+     return;
+     
    /* Close the bfd.  */
!   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 ()));
  }


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]