]> git.proxmox.com Git - qemu.git/commitdiff
sh4: Fix potential crash in debug code
authorStefan Weil <weil@mail.berlios.de>
Wed, 20 Jul 2011 18:56:35 +0000 (20:56 +0200)
committerStefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Fri, 2 Sep 2011 09:49:12 +0000 (10:49 +0100)
cppcheck reports this error:

qemu/hw/sh_intc.c:390: error: Possible null pointer dereference:
 s - otherwise it is redundant to check if s is null at line 385

If s were NULL, the printf() statement would crash.
Setting braces fixes this bug.

Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Reviewed-by: Andreas Färber <andreas.faerber@web.de>
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
hw/sh_intc.c

index ecb46e5856a539acbba4ac647c06c22cb2513ca4..e07424f2a1651b2d9bb0b740ae0dad0006acca09 100644 (file)
@@ -382,13 +382,14 @@ void sh_intc_register_sources(struct intc_desc *desc,
 
        sh_intc_register_source(desc, vect->enum_id, groups, nr_groups);
        s = sh_intc_source(desc, vect->enum_id);
-       if (s)
-           s->vect = vect->vect;
+        if (s) {
+            s->vect = vect->vect;
 
 #ifdef DEBUG_INTC_SOURCES
-       printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
-              vect->enum_id, s->vect, s->enable_count, s->enable_max);
+            printf("sh_intc: registered source %d -> 0x%04x (%d/%d)\n",
+                   vect->enum_id, s->vect, s->enable_count, s->enable_max);
 #endif
+        }
     }
 
     if (groups) {