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]: Catch sh_insn_info() returning NULL


Hi Guys,

  I am checking in the patch below to fix a seg-fault in an SH
  targeted linker that can occur when a call to sh_insn_info() returns
  NULL, but the return value was being used without being checked.
  (If it matters, the insns in question were 0x429e and 0xf2bd).

Cheers
  Nick

bfd/ChangeLog
2006-07-13  Nick Clifton  <nickc@redhat.com>

	* coff-sh.c (_bfd_sh_align_load_span): Catch sh_insn_info()
	returning a NULL value.

Index: bfd/coff-sh.c
===================================================================
RCS file: /cvs/src/src/bfd/coff-sh.c,v
retrieving revision 1.33
diff -c -3 -p -r1.33 coff-sh.c
*** bfd/coff-sh.c	4 May 2005 15:53:03 -0000	1.33
--- bfd/coff-sh.c	13 Jul 2006 09:04:04 -0000
*************** _bfd_sh_align_load_span (abfd, sec, cont
*** 2510,2517 ****
  
  		  next2_insn = bfd_get_16 (abfd, contents + i + 4);
  		  next2_op = sh_insn_info (next2_insn);
! 		  if ((next2_op->flags & (LOAD | STORE)) == 0
! 		      && sh_load_use (insn, op, next2_insn, next2_op))
  		    ok = FALSE;
  		}
  
--- 2510,2518 ----
  
  		  next2_insn = bfd_get_16 (abfd, contents + i + 4);
  		  next2_op = sh_insn_info (next2_insn);
! 		  if (next2_op == NULL
! 		      || ((next2_op->flags & (LOAD | STORE)) == 0
! 			  && sh_load_use (insn, op, next2_insn, next2_op)))
  		    ok = FALSE;
  		}
  


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