QObject patches patches for 2020-11-17
-----BEGIN PGP SIGNATURE----- iQJGBAABCAAwFiEENUvIs9frKmtoZ05fOHC0AOuRhlMFAl+z4QISHGFybWJydUBy ZWRoYXQuY29tAAoJEDhwtADrkYZTExwP/3OpulmnDvC4axDuGxrW7YvYS418Bkvp EljAiFghf8ZkBDNRupTUehL0CD5waq0fY2l306CDPji2emxr+PmcMWLipwgbBuUU sSmst5SB6naCr0Ce0xzVJ71gIjBx+RbLJostPZ4wEtgZciIoGNZZN1rdK30xBgRN 8LmUjRg3xAOmRct+yOfYSjTcVLSvZ2HttrY+4rbuWRqvf5zkmHggLUFTCoN5ntbd vVRfqUsuNg4OwFApXzvKlwM5BU9gA3CfMLus24ebTe3YzczbpIQizVt9v756ZqkD 6ATKX9qfeBiMBAwf5zOjxQcD/t4Jy/7WUR9UvSHjr7yTTVZ2yIFlKKHBEKyhdn7+ qMesLqA159g3zYXKC30dDhuKOgVyp7c5Mh8i4tIuUcJufxY6T2WKKLs52I/lLrXk 2ZN92MseiTRPpdrqVgQl86f2oL/6T+OJWh2cOnnTaRJ7N7syIRkloa4Xtwp7Z/JL 5Ib7EBG8tClQSsoCoIJB1uJWwTvsnGvQN7AWA5KiBYupiuO0WAew10LopSAkkLaU RUIdIMpKRj0Pa9YEpqRF1JJWXsuve1674NKB+kV3Ui+s0GF9mIQSmdECXtydzsPf k6Jh5uSUvQl+ESQ7W0mYsFDE76k4i0rBvYDF8vyKUSELPJm3JwCVcth/kS647sh4 2GW/U+56fi4l =KBpq -----END PGP SIGNATURE----- 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>
This commit is contained in:
commit
84dae21050
@ -257,8 +257,9 @@ static JSONToken *parser_context_peek_token(JSONParserContext *ctxt)
|
|||||||
*/
|
*/
|
||||||
static int parse_pair(JSONParserContext *ctxt, QDict *dict)
|
static int parse_pair(JSONParserContext *ctxt, QDict *dict)
|
||||||
{
|
{
|
||||||
|
QObject *key_obj = NULL;
|
||||||
|
QString *key;
|
||||||
QObject *value;
|
QObject *value;
|
||||||
QString *key = NULL;
|
|
||||||
JSONToken *peek, *token;
|
JSONToken *peek, *token;
|
||||||
|
|
||||||
peek = parser_context_peek_token(ctxt);
|
peek = parser_context_peek_token(ctxt);
|
||||||
@ -267,7 +268,8 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict)
|
|||||||
goto out;
|
goto out;
|
||||||
}
|
}
|
||||||
|
|
||||||
key = qobject_to(QString, parse_value(ctxt));
|
key_obj = parse_value(ctxt);
|
||||||
|
key = qobject_to(QString, key_obj);
|
||||||
if (!key) {
|
if (!key) {
|
||||||
parse_error(ctxt, peek, "key is not a string in object");
|
parse_error(ctxt, peek, "key is not a string in object");
|
||||||
goto out;
|
goto out;
|
||||||
@ -297,13 +299,11 @@ static int parse_pair(JSONParserContext *ctxt, QDict *dict)
|
|||||||
|
|
||||||
qdict_put_obj(dict, qstring_get_str(key), value);
|
qdict_put_obj(dict, qstring_get_str(key), value);
|
||||||
|
|
||||||
qobject_unref(key);
|
qobject_unref(key_obj);
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
out:
|
out:
|
||||||
qobject_unref(key);
|
qobject_unref(key_obj);
|
||||||
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1415,6 +1415,14 @@ static void invalid_dict_comma(void)
|
|||||||
g_assert(obj == NULL);
|
g_assert(obj == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void invalid_dict_key(void)
|
||||||
|
{
|
||||||
|
Error *err = NULL;
|
||||||
|
QObject *obj = qobject_from_json("{32:'abc'}", &err);
|
||||||
|
error_free_or_abort(&err);
|
||||||
|
g_assert(obj == NULL);
|
||||||
|
}
|
||||||
|
|
||||||
static void unterminated_literal(void)
|
static void unterminated_literal(void)
|
||||||
{
|
{
|
||||||
Error *err = NULL;
|
Error *err = NULL;
|
||||||
@ -1500,6 +1508,7 @@ int main(int argc, char **argv)
|
|||||||
g_test_add_func("/errors/unterminated/dict_comma", unterminated_dict_comma);
|
g_test_add_func("/errors/unterminated/dict_comma", unterminated_dict_comma);
|
||||||
g_test_add_func("/errors/invalid_array_comma", invalid_array_comma);
|
g_test_add_func("/errors/invalid_array_comma", invalid_array_comma);
|
||||||
g_test_add_func("/errors/invalid_dict_comma", invalid_dict_comma);
|
g_test_add_func("/errors/invalid_dict_comma", invalid_dict_comma);
|
||||||
|
g_test_add_func("/errors/invalid_dict_key", invalid_dict_key);
|
||||||
g_test_add_func("/errors/unterminated/literal", unterminated_literal);
|
g_test_add_func("/errors/unterminated/literal", unterminated_literal);
|
||||||
g_test_add_func("/errors/limits/nesting", limits_nesting);
|
g_test_add_func("/errors/limits/nesting", limits_nesting);
|
||||||
g_test_add_func("/errors/multiple_values", multiple_values);
|
g_test_add_func("/errors/multiple_values", multiple_values);
|
||||||
|
Loading…
Reference in New Issue
Block a user