GNOME Bugzilla – Bug 781914
gst_deinit() might be called without calling init_post and segfaults
Last modified: 2017-12-24 15:23:19 UTC
If you run gtk-play, from gst-example, with an unknown parameter it crashes at gst_deinit(). This is because gst_deinit() is called without registering a type, which is dereferenced. And this is seems to be the logic of GApplication. $ gtk-play -v Unknown option -v Segmentation fault (core dumped) After fixing that (first patch), a lot of critical log messages appeared. The second patch aims to fix those critical logs.
Created attachment 350677 [details] [review] gst: check non-null before dereference It is possible to use gst_deinit() without registering the base classes. For example, when using gst_init_get_option_group() and call the program with an invalid parameter. In that case, gst_deinit() will lead to a segmentation fault, since there is a dereference to a pointer that is null. This patch validates if the type is non-null before dereferencing it.
Created attachment 350678 [details] [review] gst: unref instantiated classes It is possible to use gst_deinit() without registering the base classes. For example, when using gst_init_get_option_group() and call the program with an invalid parameter. When unrefing non-instantiated classes a critical log message is thrown. This patch adds checks for the type before unref it.
Or how about we just add a guard to gst_deinit() to make sure gst_initialized has been set to TRUE ?
(In reply to Tim-Philipp Müller from comment #3) > Or how about we just add a guard to gst_deinit() to make sure > gst_initialized has been set to TRUE ? I thought about that, but I wonder why it wasn't placed before if it looks obvious, so played safe.
Comment on attachment 350677 [details] [review] gst: check non-null before dereference Attachment 350677 [details] pushed as d108ed2 - gst: check non-null before dereference
Let's KISS then: commit 252ce5a093178b415a74776f0153390e03338cab (HEAD -> master) Author: Tim-Philipp Müller <tim@centricular.com> Date: Sun Dec 24 16:21:38 2017 +0100 Skip gst_deinit() if gstreamer was not initialized properly Can happen if an error occurs during option parsing, for example. https://bugzilla.gnome.org/show_bug.cgi?id=781914