GNOME Bugzilla – Bug 710313
Memory leak in g_key_file_get_(u)int64 with invalid integer values
Last modified: 2013-10-23 04:22:09 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; }
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>
Review of attachment 257876 [details] [review]: oh, good catch.
Attachment 257876 [details] pushed as 1b59252 - GKeyfile: don't leak on failed get_(u)int64