GNOME Bugzilla – Bug 760022
Memory leak in gvariant-parser.c
Last modified: 2017-11-08 12:38:48 UTC
Created attachment 318060 [details] [review] Memory leak fix In File gvariant-parser.c "bytestring_parse" function memory is assigned to gchar pointer variable str as below str = g_malloc (length); but in switch cases while returning NULL. str variable is going out of scope and memory assigned to str is not freed. Code modification is as Below : Before : str = g_malloc (length); ..... while (token[i] != quote) switch (token[i]) { case '\0': parser_set_error (error, &ref, NULL, G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT, "unterminated string constant"); g_free (token); .... After : str = g_malloc (length); ….... while (token[i] != quote) switch (token[i]) { case '\0': parser_set_error (error, &ref, NULL, G_VARIANT_PARSE_ERROR_UNTERMINATED_STRING_CONSTANT, "unterminated string constant"); g_free (token); g_free (str); return NULL;
*** Bug 777076 has been marked as a duplicate of this bug. ***
Comment on attachment 318060 [details] [review] Memory leak fix This looks correct to me. Thanks for the patch, and sorry for the delay in reviewing and applying it. I’ll add a commit message to it before pushing. In future, please provide git-formatted patches (`git format-patch -1`).