[PATCH] winedbg: check for NULL in packet_write_registers (Coverity)

Marcus Meissner marcus at jet.franken.de
Sat Jan 31 15:36:22 CST 2009


Hi,

CID 214, not so sure if this happens at all and if a check
here is useful.

Ciao, Marcus
---
 programs/winedbg/gdbproxy.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

diff --git a/programs/winedbg/gdbproxy.c b/programs/winedbg/gdbproxy.c
index 9026b37..4ec19ce 100644
--- a/programs/winedbg/gdbproxy.c
+++ b/programs/winedbg/gdbproxy.c
@@ -1261,10 +1261,12 @@ static enum packet_return packet_write_registers(struct gdb_context* gdbctx)
 
     for (i = 0; i < cpu_num_regs; i++)
         hex_from(cpu_register(pctx, i), &gdbctx->in_packet[8 * i], 4);
-    if (pctx != &gdbctx->context && !SetThreadContext(gdbctx->other_thread->handle, pctx))
+    if ((pctx != &gdbctx->context) && (!gdbctx->other_thread || !SetThreadContext(gdbctx->other_thread->handle, pctx)))
     {
-        if (gdbctx->trace & GDBPXY_TRC_WIN32_ERROR)
-            fprintf(stderr, "Cannot set context on thread %04x\n", gdbctx->other_thread->tid);
+        if (gdbctx->trace & GDBPXY_TRC_WIN32_ERROR) {
+            if (gdbctx->other_thread)
+                fprintf(stderr, "Cannot set context on thread %04x\n", gdbctx->other_thread->tid);
+        }
         return packet_error;
     }
     return packet_ok;
-- 
1.5.6



More information about the wine-patches mailing list