|
|
9ae3a8 |
From a781053c1b5084ba32b86229b98b9601c990722c Mon Sep 17 00:00:00 2001
|
|
|
9ae3a8 |
From: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Date: Wed, 27 Jul 2016 07:35:13 +0200
|
|
|
9ae3a8 |
Subject: [PATCH 15/16] json-streamer: fix double-free on exiting during a
|
|
|
9ae3a8 |
parse
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
RH-Author: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Message-id: <1469604913-12442-17-git-send-email-armbru@redhat.com>
|
|
|
9ae3a8 |
Patchwork-id: 71484
|
|
|
9ae3a8 |
O-Subject: [RHEL-7.3 qemu-kvm PATCH v2 15/15] json-streamer: fix double-free on exiting during a parse
|
|
|
9ae3a8 |
Bugzilla: 1276036
|
|
|
9ae3a8 |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: John Snow <jsnow@redhat.com>
|
|
|
9ae3a8 |
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Now that json-streamer tries not to leak tokens on incomplete parse,
|
|
|
9ae3a8 |
the tokens can be freed twice if QEMU destroys the json-streamer
|
|
|
9ae3a8 |
object during the parser->emit call. To fix this, create the new
|
|
|
9ae3a8 |
empty GQueue earlier, so that it is already in place when the old
|
|
|
9ae3a8 |
one is passed to parser->emit.
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
Reported-by: Changlong Xie <xiecl.fnst@cn.fujitsu.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
Message-Id: <1467636059-12557-1-git-send-email-pbonzini@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
9ae3a8 |
(cherry picked from commit a942d8fa01f65279cdc135f4294db611bbc088ef)
|
|
|
9ae3a8 |
Signed-off-by: Markus Armbruster <armbru@redhat.com>
|
|
|
9ae3a8 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
9ae3a8 |
---
|
|
|
9ae3a8 |
qobject/json-streamer.c | 8 ++++++--
|
|
|
9ae3a8 |
1 file changed, 6 insertions(+), 2 deletions(-)
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
diff --git a/qobject/json-streamer.c b/qobject/json-streamer.c
|
|
|
9ae3a8 |
index 3c7d6be..7d041e1 100644
|
|
|
9ae3a8 |
--- a/qobject/json-streamer.c
|
|
|
9ae3a8 |
+++ b/qobject/json-streamer.c
|
|
|
9ae3a8 |
@@ -38,6 +38,7 @@ static void json_message_process_token(JSONLexer *lexer, GString *input,
|
|
|
9ae3a8 |
{
|
|
|
9ae3a8 |
JSONMessageParser *parser = container_of(lexer, JSONMessageParser, lexer);
|
|
|
9ae3a8 |
JSONToken *token;
|
|
|
9ae3a8 |
+ GQueue *tokens;
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
switch (type) {
|
|
|
9ae3a8 |
case JSON_LCURLY:
|
|
|
9ae3a8 |
@@ -95,9 +96,12 @@ out_emit:
|
|
|
9ae3a8 |
/* send current list of tokens to parser and reset tokenizer */
|
|
|
9ae3a8 |
parser->brace_count = 0;
|
|
|
9ae3a8 |
parser->bracket_count = 0;
|
|
|
9ae3a8 |
- /* parser->emit takes ownership of parser->tokens. */
|
|
|
9ae3a8 |
- parser->emit(parser, parser->tokens);
|
|
|
9ae3a8 |
+ /* parser->emit takes ownership of parser->tokens. Remove our own
|
|
|
9ae3a8 |
+ * reference to parser->tokens before handing it out to parser->emit.
|
|
|
9ae3a8 |
+ */
|
|
|
9ae3a8 |
+ tokens = parser->tokens;
|
|
|
9ae3a8 |
parser->tokens = g_queue_new();
|
|
|
9ae3a8 |
+ parser->emit(parser, tokens);
|
|
|
9ae3a8 |
parser->token_size = 0;
|
|
|
9ae3a8 |
}
|
|
|
9ae3a8 |
|
|
|
9ae3a8 |
--
|
|
|
9ae3a8 |
1.8.3.1
|
|
|
9ae3a8 |
|