qemu-trivial
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code


From: Stefan Weil
Subject: Re: [Qemu-trivial] [PATCH] sh4: Fix potential crash in debug code
Date: Sat, 13 Aug 2011 11:25:05 +0200
User-agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.1.16) Gecko/20110702 Iceowl/1.0b1 Icedove/3.0.11

Am 20.07.2011 20:56, schrieb Stefan Weil:
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<address@hidden>
---
  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) {

Ping?




reply via email to

[Prev in Thread] Current Thread [Next in Thread]