wsutil: fix json-glib memleaks and warning

Fix memleaks and complaint when trying to load non-JSON file as JSON:
"GError set over the top of a previous GError or uninitialized memory."

Change-Id: If5ab04dbb757636f66130bf1f8de1a45748bf541
Fixes: v2.9.0rc0-276-g73a1e98f4e ("wsutil: use json-glib instead of jsmn if present.")
Reviewed-on: https://code.wireshark.org/review/27469
Petri-Dish: Peter Wu <peter@lekensteyn.nl>
Tested-by: Petri Dish Buildbot
Reviewed-by: Dario Lombardo <lomato@gmail.com>
This commit is contained in:
Peter Wu 2018-05-12 11:03:58 +02:00 committed by Dario Lombardo
parent a2376d27d7
commit 5fa2719a7d
1 changed files with 2 additions and 2 deletions

View File

@ -29,8 +29,8 @@ gboolean wsjson_is_valid_json(const guint8* buf, const size_t len)
gboolean ret = TRUE;
#ifdef HAVE_JSONGLIB
JsonParser *parser = json_parser_new();
GError* error;
ret = json_parser_load_from_data(parser, buf, len, &error);
ret = json_parser_load_from_data(parser, buf, len, NULL);
g_object_unref(parser);
#else
/* We expect no more than 1024 tokens */
guint max_tokens = 1024;