Mercurial > pidgin.yaz
changeset 25724:89d873e217c1
Fix crash when gstreamer audio or video factory can't be found. References #6605
author | Mike Ruprecht <maiku@soc.pidgin.im> |
---|---|
date | Sat, 16 Aug 2008 20:22:41 +0000 |
parents | 1d9a2296d5d2 |
children | 64080c01ee50 |
files | libpurple/media.c libpurple/media.h pidgin/gtkprefs.c |
diffstat | 3 files changed, 28 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/libpurple/media.c Fri Aug 15 04:07:00 2008 +0000 +++ b/libpurple/media.c Sat Aug 16 20:22:41 2008 +0000 @@ -749,7 +749,12 @@ purple_media_get_element(const gchar *factory_name) { GstElementFactory *factory = gst_element_factory_find(factory_name); - GstElement *element = gst_element_factory_create(factory, NULL); + GstElement *element; + + if (factory == NULL) + return NULL; + + element = gst_element_factory_create(factory, NULL); gst_object_unref(factory); return element; }
--- a/libpurple/media.h Fri Aug 15 04:07:00 2008 +0000 +++ b/libpurple/media.h Sat Aug 16 20:22:41 2008 +0000 @@ -335,7 +335,7 @@ * * @param factory_name Name of the factory to create an element from. * - * @return The element that was created. + * @return The element that was created, NULL if it couldn't find the factory. */ GstElement *purple_media_get_element(const gchar *factory_name);
--- a/pidgin/gtkprefs.c Fri Aug 15 04:07:00 2008 +0000 +++ b/pidgin/gtkprefs.c Sat Aug 16 20:22:41 2008 +0000 @@ -2112,10 +2112,14 @@ const char *plugin = value; const char *device = purple_prefs_get_string("/purple/media/video/device"); GstElement *video = purple_media_get_element(plugin); - GList *video_devices = purple_media_get_devices(video); - GList *video_items = get_device_items(video, video_devices); + GList *video_items = NULL; GList *list; - g_list_free(video_devices); + + if (video != NULL) { + GList *video_devices = purple_media_get_devices(video); + video_items = get_device_items(video, video_devices); + g_list_free(video_devices); + } if (video_items == NULL) { video_items = g_list_prepend(video_items, g_strdup("")); @@ -2165,14 +2169,20 @@ GstElement *video = purple_media_get_element(plugin); GstElement *audio = purple_media_get_element("alsasrc"); - GList *video_devices = purple_media_get_devices(video); - GList *audio_devices = purple_media_get_devices(audio); - - GList *video_items = get_device_items(video, video_devices); - GList *audio_items = get_device_items(audio, audio_devices); - - g_list_free(video_devices); - g_list_free(audio_devices); + GList *video_items = NULL; + GList *audio_items = NULL; + + if (video != NULL) { + GList *video_devices = purple_media_get_devices(video); + video_items = get_device_items(video, video_devices); + g_list_free(video_devices); + } + + if (audio != NULL) { + GList *audio_devices = purple_media_get_devices(audio); + audio_items = get_device_items(audio, audio_devices); + g_list_free(audio_devices); + } if (video_items == NULL) { video_items = g_list_prepend(video_items, "");