[Qemu-devel] [PATCH for-2.9 2/6] disas/i386: Avoid NULL pointer dereference in error case

Peter Maydell posted 6 patches 8 years, 11 months ago
[Qemu-devel] [PATCH for-2.9 2/6] disas/i386: Avoid NULL pointer dereference in error case
Posted by Peter Maydell 8 years, 11 months ago
In a code path where we hit an internal disassembler error, execution
would subsequently attempt to dereference a NULL pointer.  This
should never happen, but avoid the crash.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 disas/i386.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/disas/i386.c b/disas/i386.c
index 07f871f..f1e376c 100644
--- a/disas/i386.c
+++ b/disas/i386.c
@@ -4043,7 +4043,7 @@ print_insn (bfd_vma pc, disassemble_info *info)
 	    }
 	}
 
-      if (putop (dp->name, sizeflag) == 0)
+      if (dp->name != NULL && putop (dp->name, sizeflag) == 0)
         {
 	  for (i = 0; i < MAX_OPERANDS; ++i)
 	    {
-- 
2.7.4