]> git.sur5r.net Git - openocd/commitdiff
disassembly: fix access to undefined memory pointer upon unknown instruction
authorØyvind Harboe <oyvind.harboe@zylin.com>
Sat, 5 Nov 2011 12:13:50 +0000 (13:13 +0100)
committerSpencer Oliver <spen@spen-soft.co.uk>
Mon, 7 Nov 2011 20:37:11 +0000 (20:37 +0000)
return error message instead. Found by clang.

Change-Id: Ica109d077206236a12d007e77cc78061ffd05834
Signed-off-by: Øyvind Harboe <oyvind.harboe@zylin.com>
Reviewed-on: http://openocd.zylin.com/169
Tested-by: jenkins
Reviewed-by: Spencer Oliver <spen@spen-soft.co.uk>
src/target/arm_disassembler.c

index 36566c9932ec725a52814100e1fbfceb5429cdec..188b6ba7be58fc28cdef1b212e18d25ea2b21f32 100644 (file)
@@ -280,13 +280,13 @@ static int evaluate_ldc_stc_mcrr_mrrc(uint32_t opcode,
                {
                        instruction->type = ARM_MCRR;
                        mnemonic = "MCRR";
-               }
-
-               /* MRRC */
-               if ((opcode & 0x0ff00000) == 0x0c500000)
-               {
+               } else if ((opcode & 0x0ff00000) == 0x0c500000) {
+                       /* MRRC */
                        instruction->type = ARM_MRRC;
                        mnemonic = "MRRC";
+               } else {
+                       LOG_ERROR("Unknown instruction");
+                       return ERROR_FAIL;
                }
 
                snprintf(instruction->text, 128,