From: Luiz Capitulino <lcapitulino@redhat.com>
To: Stefan Weil <sw@weilnetz.de>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH] json-parser: Fix potential NULL pointer segfault
Date: Mon, 3 Sep 2012 17:50:12 -0300 [thread overview]
Message-ID: <20120903175012.045303ba@doriath.home> (raw)
In-Reply-To: <1346699951-27559-1-git-send-email-sw@weilnetz.de>
On Mon, 3 Sep 2012 21:19:11 +0200
Stefan Weil <sw@weilnetz.de> wrote:
> Report from smatch:
> json-parser.c:474 parse_object(62) error: potential null derefence 'dict'.
> json-parser.c:553 parse_array(75) error: potential null derefence 'list'.
>
> Label 'out' in json-parser.c can be called with list == NULL
> which is passed to QDECREF.
>
> Modify QDECREF to handle a NULL argument (inline function qobject_decref
> already handles them, too).
>
> Signed-off-by: Stefan Weil <sw@weilnetz.de>
Applied to qmp-next branch, thanks!
> ---
>
> I did not change QINCREF because there are currently no errors caused
> by that rarely used macro.
>
> This patch can be used instead of the previous patch which fixed
> the problem directly in json-parser.c
> (see http://patchwork.ozlabs.org/patch/181129/).
>
> Regards,
> Stefan Weil
>
> qobject.h | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/qobject.h b/qobject.h
> index d42386d..9124649 100644
> --- a/qobject.h
> +++ b/qobject.h
> @@ -71,7 +71,7 @@ typedef struct QObject {
>
> /* High-level interface for qobject_decref() */
> #define QDECREF(obj) \
> - qobject_decref(QOBJECT(obj))
> + qobject_decref(obj ? QOBJECT(obj) : NULL)
>
> /* Initialize an object to default values */
> #define QOBJECT_INIT(obj, qtype_type) \
next prev parent reply other threads:[~2012-09-03 20:49 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-09-03 19:19 [Qemu-devel] [PATCH] json-parser: Fix potential NULL pointer segfault Stefan Weil
2012-09-03 20:50 ` Luiz Capitulino [this message]
-- strict thread matches above, loose matches on Subject: below --
2012-09-01 10:52 Stefan Weil
2012-09-03 16:41 ` Luiz Capitulino
2012-09-03 16:53 ` Stefan Weil
2012-09-03 17:14 ` Stefan Weil
2012-09-03 17:54 ` Luiz Capitulino
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=20120903175012.045303ba@doriath.home \
--to=lcapitulino@redhat.com \
--cc=qemu-devel@nongnu.org \
--cc=sw@weilnetz.de \
/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).