summaryrefslogtreecommitdiff
path: root/opcodes/s12z-dis.c
diff options
context:
space:
mode:
authorJohn Darrington <john@darrington.wattle.id.au>2019-01-04 09:44:58 +0100
committerJohn Darrington <john@darrington.wattle.id.au>2019-01-09 19:47:06 +0100
commit448b8ca86519cce1216c9db5f0236604a6a33320 (patch)
treebff31676ee1c6972f2c87ff582a2ca7844494531 /opcodes/s12z-dis.c
parent39f286cd585226ad98c2cd94ee0f96988b3696ce (diff)
downloadbinutils-gdb-448b8ca86519cce1216c9db5f0236604a6a33320.tar.gz
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.
Diffstat (limited to 'opcodes/s12z-dis.c')
-rw-r--r--opcodes/s12z-dis.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/opcodes/s12z-dis.c b/opcodes/s12z-dis.c
index 5db0b435624..d4d5fd7217f 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)
{