[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PATCH] gdbstub: Fix GDBRegisterState memory leak and use
From: |
Stefan Weil |
Subject: |
[Qemu-trivial] [PATCH] gdbstub: Fix GDBRegisterState memory leak and use g_new0 to allocate it |
Date: |
Thu, 17 Nov 2011 19:22:58 +0100 |
cppcheck reported a memory leak which is fixed here.
I also replaced the corresponding g_malloc0 by g_new0 because
that helps reviewers, and it is required by latest recommendations
anyway.
Signed-off-by: Stefan Weil <address@hidden>
---
gdbstub.c | 6 ++++--
1 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/gdbstub.c b/gdbstub.c
index a25f404..031a240 100644
--- a/gdbstub.c
+++ b/gdbstub.c
@@ -1781,7 +1781,7 @@ void gdb_register_coprocessor(CPUState * env,
GDBRegisterState **p;
static int last_reg = NUM_CORE_REGS;
- s = (GDBRegisterState *)g_malloc0(sizeof(GDBRegisterState));
+ s = g_new0(GDBRegisterState, 1);
s->base_reg = last_reg;
s->num_regs = num_regs;
s->get_reg = get_reg;
@@ -1790,8 +1790,10 @@ void gdb_register_coprocessor(CPUState * env,
p = &env->gdb_regs;
while (*p) {
/* Check for duplicates. */
- if (strcmp((*p)->xml, xml) == 0)
+ if (strcmp((*p)->xml, xml) == 0) {
+ g_free(s);
return;
+ }
p = &(*p)->next;
}
/* Add to end of list. */
--
1.7.2.5
- [Qemu-trivial] [PATCH] gdbstub: Fix GDBRegisterState memory leak and use g_new0 to allocate it,
Stefan Weil <=