GNOME Bugzilla – Bug 739368
gl: small memory leak in gl shader
Last modified: 2014-11-03 00:22:45 UTC
Created attachment 289605 [details] [review] fix CID #1212171 Resource leak Memory is only freed in one side of the if. Not pretty but adding a g_free in the FALSE clause.
Code around it for easier review. > if (arraysize) { > char *s = g_malloc (strlen (vartype) + 32); > sprintf (s, "%s[%d]", vartype, arraysize); > if (strcmp (t, s)) { > g_free (s); > goto parse_error; > } > g_free (s); > } else {
Looks good to me, but perhaps the g_malloc + sprintf should be consolidated into a g_strdup_printf() ?
Created attachment 289750 [details] [review] consolidate into g_strdup_printf() Good idea, consolidated.
Created attachment 289751 [details] [review] Might as well use g_strcmp0 () then as well.
Why? None of the two arguments will ever be NULL.
Because it feels weird to use strcmp when one of the parameters is a gchar. But I understand that the only difference between the two functions is that g_strcmp0 handles NULL gracefully. I can merge attachment 289750 [details] [review]. Don't really mind.
Comment on attachment 289750 [details] [review] consolidate into g_strdup_printf() Merged commit 658f403a26c2242852a8c130bc5779c4268b2cae
Comment on attachment 289751 [details] [review] Might as well use g_strcmp0 () then as well. No need for g_strcmp0 ()
Thanks Tim! :)