This is the mail archive of the binutils-cvs@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]

[binutils-gdb] S12Z: Don't crash when disassembling invalid instructions.


https://sourceware.org/git/gitweb.cgi?p=binutils-gdb.git;h=448b8ca86519cce1216c9db5f0236604a6a33320

commit 448b8ca86519cce1216c9db5f0236604a6a33320
Author: John Darrington <john@darrington.wattle.id.au>
Date:   Fri Jan 4 09:44:58 2019 +0100

    S12Z: Don't crash when disassembling invalid instructions.
    
    Check for null before dereferencing an operand pointer.  Normally
    this situation should never arise, but could happen if a "partial"
    instruction is encountered at the end of a file or section.
    
    opcodes/
    	* s12z-dis.c (print_insn_s12z):  Do not dereference an
    	operand if it is null.

Diff:
---
 opcodes/ChangeLog  | 4 +++-
 opcodes/s12z-dis.c | 4 ++--
 2 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/opcodes/ChangeLog b/opcodes/ChangeLog
index d17ee10..cf7d55e 100644
--- a/opcodes/ChangeLog
+++ b/opcodes/ChangeLog
@@ -1,6 +1,8 @@
 2019-01-09  John Darrington <john@darrington.wattle.id.au>
 
-        * s12z-dis.c (opr_emit_disassembly): Do not omit an index if it is
+	* s12z-dis.c (print_insn_s12z):  Do not dereference an operand
+	if it is null.
+	-dis.c (opr_emit_disassembly): Do not omit an index if it is
 	zero.
 
 2019-01-09  Andrew Paprocki  <andrew@ishiboo.com>
diff --git a/opcodes/s12z-dis.c b/opcodes/s12z-dis.c
index 5db0b43..d4d5fd7 100644
--- a/opcodes/s12z-dis.c
+++ b/opcodes/s12z-dis.c
@@ -351,7 +351,7 @@ print_insn_s12z (bfd_vma memaddr, struct disassemble_info* info)
 		 (struct mem_read_abstraction_base *) &mra);
 
   (info->fprintf_func) (info->stream, "%s", mnemonics[(long)operator]);
-  
+
   /* Ship out size sufficies for those instructions which
      need them.  */
   if (osize == -1)
@@ -359,7 +359,7 @@ print_insn_s12z (bfd_vma memaddr, struct disassemble_info* info)
       bool suffix = false;
       for (o = 0; o < n_operands; ++o)
 	{
-	  if (operands[o]->osize != -1)
+	  if (operands[o] && operands[o]->osize != -1)
 	    {
 	      if (!suffix)
 		{


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