From: "Marc-André Lureau" <marcandre.lureau@redhat.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [PATCH 2/5] dump: Fix g_array_unref(NULL) in dump-guest-memory
Date: Tue, 31 Oct 2023 10:53:52 +0400 [thread overview]
Message-ID: <CAMxuvaxy_mwut2rH0cAOaOgiRTTeBBBCKprTS4bmetHqb7C8Ww@mail.gmail.com> (raw)
In-Reply-To: <20231030133712.2822276-3-armbru@redhat.com>
Hi
On Mon, Oct 30, 2023 at 5:37 PM Markus Armbruster <armbru@redhat.com> wrote:
>
> When dump_init()'s check for non-zero @length fails, dump_cleanup()
> passes null s->string_table_buf to g_array_unref(), which spews "GLib:
> g_array_unref: assertion 'array' failed" to stderr.
>
> Guard the g_array_unref().
>
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
> ---
> dump/dump.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/dump/dump.c b/dump/dump.c
> index a1fad17f9c..d8ea364af2 100644
> --- a/dump/dump.c
> +++ b/dump/dump.c
> @@ -100,7 +100,9 @@ static int dump_cleanup(DumpState *s)
> memory_mapping_list_free(&s->list);
> close(s->fd);
> g_free(s->guest_note);
> - g_array_unref(s->string_table_buf);
> + if (s->string_table_buf) {
> + g_array_unref(s->string_table_buf);
> + }
or:
g_clear_pointer(&s->string_table_buf, g_array_unref)
> s->guest_note = NULL;
> if (s->resume) {
> if (s->detached) {
> --
> 2.41.0
>
next prev parent reply other threads:[~2023-10-31 6:55 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-30 13:37 [PATCH 0/5] dump: Minor fixes & improvements Markus Armbruster
2023-10-30 13:37 ` [PATCH 1/5] dump: Rename qmp_dump_guest_memory() parameter to match QAPI schema Markus Armbruster
2023-10-31 6:54 ` Marc-André Lureau
2023-10-30 13:37 ` [PATCH 2/5] dump: Fix g_array_unref(NULL) in dump-guest-memory Markus Armbruster
2023-10-31 6:53 ` Marc-André Lureau [this message]
2023-10-31 9:02 ` Markus Armbruster
2023-10-31 9:06 ` Markus Armbruster
2023-10-31 10:09 ` Marc-André Lureau
2023-10-30 13:37 ` [PATCH 3/5] dump: Recognize "fd:" protocols on Windows hosts Markus Armbruster
2023-10-31 6:55 ` Marc-André Lureau
2023-10-30 13:37 ` [PATCH 4/5] dump: Improve some dump-guest-memory error messages Markus Armbruster
2023-10-30 14:05 ` Philippe Mathieu-Daudé
2023-10-31 5:44 ` Markus Armbruster
2023-10-30 13:37 ` [PATCH 5/5] dump: Drop redundant check for empty dump Markus Armbruster
2023-10-31 10:23 ` Marc-André Lureau
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=CAMxuvaxy_mwut2rH0cAOaOgiRTTeBBBCKprTS4bmetHqb7C8Ww@mail.gmail.com \
--to=marcandre.lureau@redhat.com \
--cc=armbru@redhat.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 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).