diff options
| author | Peter Maydell <peter.maydell@linaro.org> | 2020-11-17 21:06:58 +0000 |
|---|---|---|
| committer | Peter Maydell <peter.maydell@linaro.org> | 2020-11-17 21:06:58 +0000 |
| commit | 84dae210506784945ec8342a613d7bd62ae6ec62 (patch) | |
| tree | 0f85638c786f7f11ff9cd1305ea3ade9b76e6544 /qobject/json-parser.c | |
| parent | c446ac37b7e79d971e55b3423981ada0c3db6459 (diff) | |
| parent | 922d42bb0d08c154602dd9112da00d22d2b46579 (diff) | |
| download | focaccia-qemu-84dae210506784945ec8342a613d7bd62ae6ec62.tar.gz focaccia-qemu-84dae210506784945ec8342a613d7bd62ae6ec62.zip | |
Merge remote-tracking branch 'remotes/armbru/tags/pull-qobject-2020-11-17' into staging
QObject patches patches for 2020-11-17 # gpg: Signature made Tue 17 Nov 2020 14:41:06 GMT # gpg: using RSA key 354BC8B3D7EB2A6B68674E5F3870B400EB918653 # gpg: issuer "armbru@redhat.com" # gpg: Good signature from "Markus Armbruster <armbru@redhat.com>" [full] # gpg: aka "Markus Armbruster <armbru@pond.sub.org>" [full] # Primary key fingerprint: 354B C8B3 D7EB 2A6B 6867 4E5F 3870 B400 EB91 8653 * remotes/armbru/tags/pull-qobject-2020-11-17: json: Fix a memleak in parse_pair() Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Diffstat (limited to 'qobject/json-parser.c')
| -rw-r--r-- | qobject/json-parser.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/qobject/json-parser.c b/qobject/json-parser.c index d083810d37..c0f521b56b 100644 --- a/qobject/json-parser.c +++ b/qobject/json-parser.c @@ -257,8 +257,9 @@ static JSONToken *parser_context_peek_token(JSONParserContext *ctxt) */ static int parse_pair(JSONParserContext *ctxt, QDict *dict) { + QObject *key_obj = NULL; + QString *key; QObject *value; - QString *key = NULL; JSONToken *peek, *token; peek = parser_context_peek_token(ctxt); @@ -267,7 +268,8 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict) goto out; } - key = qobject_to(QString, parse_value(ctxt)); + key_obj = parse_value(ctxt); + key = qobject_to(QString, key_obj); if (!key) { parse_error(ctxt, peek, "key is not a string in object"); goto out; @@ -297,13 +299,11 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict) qdict_put_obj(dict, qstring_get_str(key), value); - qobject_unref(key); - + qobject_unref(key_obj); return 0; out: - qobject_unref(key); - + qobject_unref(key_obj); return -1; } |