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 710313 - Memory leak in g_key_file_get_(u)int64 with invalid integer values
Memory leak in g_key_file_get_(u)int64 with invalid integer values
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gkeyfile
2.38.x
Other Linux
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2013-10-16 18:37 UTC by Andrew Stone
Modified: 2013-10-23 04:22 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
GKeyfile: don't leak on failed get_(u)int64 (1.14 KB, patch)
2013-10-22 20:25 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Andrew Stone 2013-10-16 18:37:06 UTC
Currently, in both g_key_file_get_int64 and g_key_file_get_uint64, when g_ascii_strto(u)ll returns an error for parsing the value of a given key, rather than freeing the result of g_key_file_get_value, each function just returns. 

As it stands:

if (*s == '\0' || *end != '\0')
  {
    g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE, ...
    return 0;
  }

Should just be, in both cases:

if (*s == '\0' || *end != '\0')
  {
    g_set_error (error, G_KEY_FILE_ERROR, G_KEY_FILE_ERROR_INVALID_VALUE, ...
    g_free (s);
    return 0;
  }
Comment 1 Allison Karlitskaya (desrt) 2013-10-22 20:25:50 UTC
Created attachment 257876 [details] [review]
GKeyfile: don't leak on failed get_(u)int64

In the case that g_key_file_get_(u)int64 fails to parse the integer,
make sure we free the string before returning.

Reported by Andrew Stone <astonecc@gmail.com>
Comment 2 Matthias Clasen 2013-10-22 20:39:10 UTC
Review of attachment 257876 [details] [review]:

oh, good catch.
Comment 3 Matthias Clasen 2013-10-22 20:39:20 UTC
Review of attachment 257876 [details] [review]:

oh, good catch.
Comment 4 Allison Karlitskaya (desrt) 2013-10-23 04:22:06 UTC
Attachment 257876 [details] pushed as 1b59252 - GKeyfile: don't leak on failed get_(u)int64