Patchwork [02/12] lm32-dis: fix NULL pointer dereference

login
register
mail settings
Submitter Michael Walle
Date March 6, 2013, 9:59 p.m.
Message ID <1362607209-12232-3-git-send-email-michael@walle.cc>
Download mbox | patch
Permalink /patch/225661/
State New
Headers show

Comments

Michael Walle - March 6, 2013, 9:59 p.m.
Signed-off-by: Michael Walle <michael@walle.cc>
---
 disas/lm32.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

Patch

diff --git a/disas/lm32.c b/disas/lm32.c
index a8eefe0..1718c86 100644
--- a/disas/lm32.c
+++ b/disas/lm32.c
@@ -303,11 +303,11 @@  int print_insn_lm32(bfd_vma memaddr, struct disassemble_info *info)
                 }
                 case 'c': {
                     uint8_t csr;
-                    const char *csr_name;
+                    const Lm32CsrInfo *info;
                     csr = (op >> 21) & 0x1f;
-                    csr_name = find_csr_info(csr)->name;
-                    if (csr_name) {
-                        fprintf_fn(stream, "%s", csr_name);
+                    info = find_csr_info(csr);
+                    if (info) {
+                        fprintf_fn(stream, "%s", info->name);
                     } else {
                         fprintf_fn(stream, "0x%x", csr);
                     }