S12Z: Don't crash when disassembling invalid instructions.
authorJohn Darrington <john@darrington.wattle.id.au>
Fri, 4 Jan 2019 08:44:58 +0000 (09:44 +0100)
committerJohn Darrington <john@darrington.wattle.id.au>
Wed, 9 Jan 2019 18:47:06 +0000 (19:47 +0100)
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.

opcodes/ChangeLog
opcodes/s12z-dis.c

index d17ee102202344ec0da6d69cf7d8eded5dd5e8ec..cf7d55eb3f24ddfb2d259de41acaa9ea10e687d6 100644 (file)
@@ -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>
index 5db0b4356246bbdec00e2e6be1de7922597b979e..d4d5fd7217f03523d2f4a21c8a0998cd768d98e9 100644 (file)
@@ -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)
                {
This page took 0.025137 seconds and 4 git commands to generate.