After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686096 - Small leak in json_parse_statement
Small leak in json_parse_statement
Status: RESOLVED FIXED
Product: json-glib
Classification: Core
Component: Parser
git master
Other Linux
: Normal normal
: ---
Assigned To: json-glib-maint
json-glib-maint
Depends on:
Blocks:
 
 
Reported: 2012-10-13 17:44 UTC by Miguel Angel Cabrera Moya
Modified: 2012-10-25 15:05 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Proposed fix (818 bytes, patch)
2012-10-14 10:19 UTC, Miguel Angel Cabrera Moya
accepted-commit_now Details | Review
proposed fix (874 bytes, patch)
2012-10-23 06:47 UTC, Miguel Angel Cabrera Moya
committed Details | Review

Description Miguel Angel Cabrera Moya 2012-10-13 17:44:15 UTC
Here is the proposed fix:

diff --git a/json-glib/json-parser.c b/json-glib/json-parser.c
index 526e2de..296c1aa 100644
--- a/json-glib/json-parser.c
+++ b/json-glib/json-parser.c
@@ -760,7 +760,10 @@ json_parse_statement (JsonParser  *parser,
         /* ... and finally swallow the '=' */
         next_token = json_scanner_get_next_token (scanner);
         if (next_token != '=')
+        {
+          g_free (name);
           return '=';
+        }
 
         priv->has_assignment = TRUE;
         priv->variable_name = name;
Comment 1 André Klapper 2012-10-13 23:48:03 UTC
Thanks! 
(Attaching patches as attachments is welcome, so they can be queried for.)
Comment 2 Miguel Angel Cabrera Moya 2012-10-14 10:19:11 UTC
Created attachment 226406 [details] [review]
Proposed fix
Comment 3 Miguel Angel Cabrera Moya 2012-10-23 06:15:26 UTC
Could you review/commit the patch?

Thanks
Comment 4 Emmanuele Bassi (:ebassi) 2012-10-23 06:29:09 UTC
Review of attachment 226406 [details] [review]:

thanks for the patch; there's one minor coding style issue that has to be fixed before commit.

::: json-glib/json-parser.c
@@ +761,3 @@
         next_token = json_scanner_get_next_token (scanner);
         if (next_token != '=')
+        {

conding style: the curly braces should have an additional indentation level.
Comment 5 Miguel Angel Cabrera Moya 2012-10-23 06:47:08 UTC
Created attachment 227041 [details] [review]
proposed fix
Comment 6 Emmanuele Bassi (:ebassi) 2012-10-23 08:15:59 UTC
Review of attachment 227041 [details] [review]:

brilliant, thanks a lot!
Comment 7 Miguel Angel Cabrera Moya 2012-10-25 07:14:21 UTC
Could you push the patch?
Comment 8 Emmanuele Bassi (:ebassi) 2012-10-25 15:05:12 UTC
Pushed to master, thanks!