GNOME Bugzilla – Bug 755480
TRY_GET leaks string pointer
Last modified: 2015-09-28 14:16:24 UTC
TRY_GET is very useful macro, but it fails to manage string pointer because it uses gst_structure_get. https://developer.gnome.org/gstreamer/stable/gstreamer-GstStructure.html#gst-structure-get The return value of gst_structure_get_string, otherwise, doesn't need to be freed.
Created attachment 311959 [details] [review] TRY_GET leaks string pointer
Review of attachment 311959 [details] [review]: Getting: ges-structured-interface.c: In function ‘_ges_add_clip_from_struct’: ges-structured-interface.c:352:132: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] ges-structured-interface.c:352:21: warning: assignment discards ‘const’ qualifier from pointer target type [-Wdiscarded-qualifiers] now :)
Created attachment 311993 [details] [review] fix warning you are sharp in review :)
Review of attachment 311993 [details] [review]: ::: ges/ges-structured-interface.c @@ -349,3 +350,3 @@ if (layer_priority == -1) TRY_GET ("layer", G_TYPE_INT, &layer_priority, -1); - TRY_GET ("type", G_TYPE_STRING, &type_string, "GESUriClip"); + TRY_GET ("type", G_TYPE_STRING, &type_string, g_strdup ("GESUriClip")); Looks wrong to g_strdup the def value, I think it is leaked if we do not use it.
Review of attachment 311993 [details] [review]: ::: ges/ges-structured-interface.c @@ +440,2 @@ beach: + g_free (type_string); @Thibault, in here, it is freed. User should do free after calling TRY_GET for string. OR, we might define TRY_GET_STRING for the case of string. Any advice?
Oops, you right. g_strdup ("GESUriClip") will be leaked if "type" has value. I think it would be better to define TRY_GET_STRING. What is your opinion?
(In reply to Justin J. Kim from comment #6) > Oops, you right. > g_strdup ("GESUriClip") will be leaked if "type" has value. > > I think it would be better to define TRY_GET_STRING. What is your opinion? ++ :)
Created attachment 312119 [details] [review] TRY_GET_STRING