qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code
@ 2011-07-20 18:56 Stefan Weil
  2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
                   ` (4 more replies)
  0 siblings, 5 replies; 7+ messages in thread
From: Stefan Weil @ 2011-07-20 18:56 UTC (permalink / raw)
  To: qemu-devel; +Cc: qemu-trivial

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>
---
 hw/sh_intc.c |    9 +++++----
 1 files changed, 5 insertions(+), 4 deletions(-)

diff --git a/hw/sh_intc.c b/hw/sh_intc.c
index 0734da9..f73a4b0 100644
--- a/hw/sh_intc.c
+++ b/hw/sh_intc.c
@@ -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) {
-- 
1.7.2.5

^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-08-29 11:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-20 18:56 [Qemu-devel] [PATCH] sh4: Fix potential crash in debug code Stefan Weil
2011-07-20 18:56 ` [Qemu-devel] [PATCH] tcg/mips: Fix regression caused by typo (copy + paste bug) Stefan Weil
2011-07-25 10:22 ` [Qemu-devel] [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code Stefan Hajnoczi
2011-08-13  9:25 ` [Qemu-devel] " Stefan Weil
2011-08-27 19:27   ` Stefan Weil
2011-08-28 11:13 ` Andreas Färber
2011-08-29 11:39 ` [Qemu-devel] [Qemu-trivial] " Stefan Hajnoczi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).