wsutil: fix json-glib memleaks and warning
authorPeter Wu <peter@lekensteyn.nl>
Sat, 12 May 2018 09:03:58 +0000 (11:03 +0200)
committerDario Lombardo <lomato@gmail.com>
Sun, 13 May 2018 17:03:55 +0000 (17:03 +0000)
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>
wsutil/wsjson.c

index 7d5c442ecd6c7382ba05111f8bf42b38bb743bfc..c19c46c17946567fe061876c0a60b7e4ab697ec9 100644 (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;