GNOME Bugzilla – Bug 775072
memory leak in usage of gst_pad_get_current_caps() API
Last modified: 2016-12-05 09:15:16 UTC
Created attachment 340741 [details] [review] memory leak in usage of gst_pad_get_current_caps() API File:gst-plugins-bad-1.10.1/gst/mpegpsmux/mpegpsmux.c Function: mpegpsmux_create_stream() memory allocated to 'caps' at line:225 is not freed before the function returns. File:gst-plugins-bad-1.10.1/tests/examples/directfb/gstdfb.c Function: size_changed() memory allocated to 'caps' at line:86 is not freed before the function returns. Applied Fix: Added gst_caps_unref to free the allocated memory.
Review of attachment 340741 [details] [review]: Please provide patches in "git format-patch" format with a meaningful commit message, thanks! ::: gst-plugins-bad-1.10.1/gst/mpegpsmux/mpegpsmux.c @@ +231,3 @@ s = gst_caps_get_structure (caps, 0); + + gst_caps_unref (caps); This will invalidate "s", which is still used afterwards. You can only unref after "s" is not used anymore ::: gst-plugins-bad-1.10.1/tests/examples/directfb/gstdfb.c @@ +89,3 @@ s = gst_caps_get_structure (caps, 0); + + gst_caps_unref (caps); same
Created attachment 340874 [details] [review] Fix Memory leak in gst_pad_get_current_caps() API usage Added patch is in "git format-patch".
Review of attachment 340874 [details] [review]: Please put the URL to the bug report as last line in the commit message. And the patch still has the same problems as before: ::: gst/mpegpsmux/mpegpsmux.c @@ +231,2 @@ s = gst_caps_get_structure (caps, 0); + gst_caps_unref (caps); "s" becomes invalid by unreffing the caps that own it. Only unref the caps after all usage of the GstStructure is done. ::: tests/examples/directfb/gstdfb.c @@ +89,2 @@ s = gst_caps_get_structure (caps, 0); + gst_caps_unref (caps); Same
Created attachment 341021 [details] [review] Fixed memory leak in usage of gst_pad_get_current_caps() API Now I have added the patch as per the requirement. Please review the patch with all required changes.
commit aa08be43c7348dc1e0f6e968946bd810c417c267 Author: Garima Gaur <garima.g@samsung.com> Date: Wed Nov 30 10:40:42 2016 +0530 gst: Fix caps leak https://bugzilla.gnome.org/show_bug.cgi?id=775072