malloc failure cases in good plugins

Nicolas Dufresne nicolas at ndufresne.ca
Thu Dec 7 01:45:46 UTC 2017


Le jeudi 07 décembre 2017 à 03:19 +0300, Слободенюк Александр Игоревич
a écrit :
> Hello everybody!
>  
> I have been reading some gst-plugins-good sources and found , that
> case of
> memory allocation failure is tupically ignored there , at least in
> plugins "pngenc" and "avimux".
>  
> Example:
>  
> gst_avi_mux_riff_get_avix_header (guint32 datax_size)
> {
>   GstBuffer *buffer;
>   GstMapInfo map;
>  
>   buffer = gst_buffer_new_and_alloc (24);

This is fine, the C Library we use, GLib will abort the application if
we run out of memory. If you run-out of virtual memory, you have a
larger problem, better kill applications before it becomes nasty and
hack-able.

>  
>   gst_buffer_map (buffer, &map, GST_MAP_WRITE);

This though is not has good, we usually always check the return value
of gst_buffer_map(). This case is particular, the buffer/memory has
just been allocated, it's not shared yet, so I don't see how this could
possibly fail.

>   memcpy (map.data + 0, "RIFF", 4);
>  
> ......
> .....
>  
> In my build of glib and gstreamer "gst_buffer_new_and_alloc" after
> all uses just libc's malloc call. Watched in the debugger.
> So, could you please help me to figure out, if that are bugs to be
> fixed, or I just don't understand (missed) something?
>  
> Thanks.
>  
>  
> -- 
> С уважением,
> Слободенюк Александр Игоревич
>  
> контактный телефон: +7-925-050-64-62
>  
> _______________________________________________
> gstreamer-devel mailing list
> gstreamer-devel at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/gstreamer-devel


More information about the gstreamer-devel mailing list