aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCharles Kerr <charles@transmissionbt.com>2010-04-11 19:18:30 +0200
committerMax Kellermann <max@duempel.org>2010-04-11 19:18:30 +0200
commit6a958980388727048effaea081b68c8debfaa6df (patch)
tree5de8c0420631e89ae367c5982a642f20a512e78b
parentc52f469c9cff4ad6aeede40ff3254d695a9ba603 (diff)
downloadmpd-6a958980388727048effaea081b68c8debfaa6df.tar.gz
mpd-6a958980388727048effaea081b68c8debfaa6df.tar.xz
mpd-6a958980388727048effaea081b68c8debfaa6df.zip
decoder/ffmpeg: fix crash on startup in mpd_ffmpeg_log_callback()
What's happening is the `ptr' argument to that function is NULL for me every time. `ptr' is unconditionally dereferenced to generate a log message, and this is where mpd crashes. Attached is a simple patch that tests for NULL and omits the log. With this patch the crash disappeared and mpd went back to working well.
Diffstat (limited to '')
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c13
1 files changed, 9 insertions, 4 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index d4d6224d2..4f956f555 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -67,11 +67,16 @@ static void
mpd_ffmpeg_log_callback(G_GNUC_UNUSED void *ptr, int level,
const char *fmt, va_list vl)
{
- const AVClass *cls = *(const AVClass *const*)ptr;
- char *domain = g_strconcat(G_LOG_DOMAIN, "/", cls->item_name(ptr), NULL);
+ const AVClass * cls = NULL;
- g_logv(domain, level_ffmpeg_to_glib(level), fmt, vl);
- g_free(domain);
+ if (ptr != NULL)
+ cls = *(const AVClass *const*)ptr;
+
+ if (cls != NULL) {
+ char *domain = g_strconcat(G_LOG_DOMAIN, "/", cls->item_name(ptr), NULL);
+ g_logv(domain, level_ffmpeg_to_glib(level), fmt, vl);
+ g_free(domain);
+ }
}
#endif /* !OLD_FFMPEG_INCLUDES */