[cheese] CheeseCamera: Avoid crash when gst_*_message_parse() fails.
- From: David King <davidk src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [cheese] CheeseCamera: Avoid crash when gst_*_message_parse() fails.
- Date: Mon, 7 Mar 2011 09:41:57 +0000 (UTC)
commit dd6eb3b6f0784603cdd744931afb72a19204398d
Author: Murray Cumming <murrayc murrayc com>
Date: Fri Feb 25 17:49:37 2011 +0100
CheeseCamera: Avoid crash when gst_*_message_parse() fails.
* libcheese/cheese-camera.c: cheese_camera_bus_message_cb():
Sometimes the GstMessage's internal structure seems to not be for a
warning message, even when GST_MESSAGE_TYPE() says that it is.
We should generally check the err before dereferencing it anyway,
and that prevents this from crashing cheese.
This happens when stopping video recording. The video is saved anyway.
libcheese/cheese-camera.c | 30 ++++++++++++++++++++----------
1 files changed, 20 insertions(+), 10 deletions(-)
---
diff --git a/libcheese/cheese-camera.c b/libcheese/cheese-camera.c
index 69b47cd..551bbd4 100644
--- a/libcheese/cheese-camera.c
+++ b/libcheese/cheese-camera.c
@@ -215,23 +215,33 @@ cheese_camera_bus_message_cb (GstBus *bus, GstMessage *message, CheeseCamera *ca
}
case GST_MESSAGE_WARNING:
{
- GError *err;
- gchar *debug;
-
+ GError *err = NULL;
+ gchar *debug = NULL;
gst_message_parse_warning (message, &err, &debug);
- g_warning ("%s\n", err->message);
- g_error_free (err);
+
+ if (err && err->message) {
+ g_warning ("%s\n", err->message);
+ g_error_free (err);
+ } else {
+ g_warning ("Unparsable GST_MESSAGE_WARNING message.\n");
+ }
+
g_free (debug);
break;
}
case GST_MESSAGE_ERROR:
{
- GError *err;
- gchar *debug;
-
+ GError *err = NULL;
+ gchar *debug = NULL;
gst_message_parse_error (message, &err, &debug);
- g_warning ("%s\n", err->message);
- g_error_free (err);
+
+ if (err && err->message) {
+ g_warning ("%s\n", err->message);
+ g_error_free (err);
+ } else {
+ g_warning ("Unparsable GST_MESSAGE_ERROR message.\n");
+ }
+
g_free (debug);
break;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]