From: Stefan Weil <sw@weilnetz.de>
To: Anthony Liguori <aliguori@us.ibm.com>
Cc: Blue Swirl <blauwirbel@gmail.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH v2] gdbstub: Fix memory leak
Date: Fri, 11 Nov 2011 22:09:01 +0100 [thread overview]
Message-ID: <4EBD8EED.8070001@weilnetz.de> (raw)
In-Reply-To: <1318969538-10479-1-git-send-email-sw@weilnetz.de>
Am 18.10.2011 22:25, schrieb Stefan Weil:
> cppcheck report:
> gdbstub.c:1781: error: Memory leak: s
>
> Rearranging of the code avoids the leak.
>
> v2:
> Replace the g_malloc0() by g_new0() (suggested by Stuart Brady).
>
> Signed-off-by: Stefan Weil<sw@weilnetz.de>
> ---
> gdbstub.c | 14 ++++++++------
> 1 files changed, 8 insertions(+), 6 deletions(-)
>
> diff --git a/gdbstub.c b/gdbstub.c
> index 4009058..8bf7167 100644
> --- a/gdbstub.c
> +++ b/gdbstub.c
> @@ -1768,12 +1768,6 @@ void gdb_register_coprocessor(CPUState * env,
> GDBRegisterState **p;
> static int last_reg = NUM_CORE_REGS;
>
> - s = (GDBRegisterState *)g_malloc0(sizeof(GDBRegisterState));
> - s->base_reg = last_reg;
> - s->num_regs = num_regs;
> - s->get_reg = get_reg;
> - s->set_reg = set_reg;
> - s->xml = xml;
> p =&env->gdb_regs;
> while (*p) {
> /* Check for duplicates. */
> @@ -1781,6 +1775,14 @@ void gdb_register_coprocessor(CPUState * env,
> return;
> p =&(*p)->next;
> }
> +
> + s = g_new0(GDBRegisterState, 1);
> + s->base_reg = last_reg;
> + s->num_regs = num_regs;
> + s->get_reg = get_reg;
> + s->set_reg = set_reg;
> + s->xml = xml;
> +
> /* Add to end of list. */
> last_reg += num_regs;
> *p = s;
>
Ping? This patch is still missing for QEMU 1.0.
Kind regards,
Stefan Weil
next prev parent reply other threads:[~2011-11-11 21:09 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-17 20:01 [Qemu-devel] [PATCH] gdbstub: Fix memory leak Stefan Weil
2011-10-18 1:13 ` Stuart Brady
2011-10-18 18:18 ` Blue Swirl
2011-10-19 0:59 ` Stuart Brady
2011-10-20 8:10 ` Stuart Brady
2011-10-23 12:48 ` Blue Swirl
2011-10-18 20:25 ` [Qemu-devel] [PATCH v2] " Stefan Weil
2011-11-11 21:09 ` Stefan Weil [this message]
2011-11-19 13:59 ` Blue Swirl
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=4EBD8EED.8070001@weilnetz.de \
--to=sw@weilnetz.de \
--cc=aliguori@us.ibm.com \
--cc=blauwirbel@gmail.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.