From 6d545e29add17f1c02ee4fe5623409ed63369c17 Mon Sep 17 00:00:00 2001 From: Edward Hervey Date: Thu, 20 Jan 2011 11:45:47 +0100 Subject: [PATCH] qtdemux: Gracefully handle mov files misusing the WAVE atoms Check that the WAVEHEADER node is present instead of blindly using it. If not present we won't be able to provide a more refined caps, but at least we won't crash. https://bugzilla.gnome.org/show_bug.cgi?id=640028 --- gst/qtdemux/qtdemux.c | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/gst/qtdemux/qtdemux.c b/gst/qtdemux/qtdemux.c index 80fd5a0..b4f9cbf 100644 --- a/gst/qtdemux/qtdemux.c +++ b/gst/qtdemux/qtdemux.c @@ -7004,31 +7004,34 @@ qtdemux_parse_trak (GstQTDemux * qtdemux, GNode * trak) guint32 headerlen; waveheadernode = qtdemux_tree_get_child_by_type (wavenode, fourcc); - waveheader = (const guint8 *) waveheadernode->data; - headerlen = QT_UINT32 (waveheader); - - if (headerlen > 8) { - gst_riff_strf_auds *header = NULL; - GstBuffer *headerbuf; - GstBuffer *extra; - - waveheader += 8; - headerlen -= 8; - - headerbuf = gst_buffer_new (); - GST_BUFFER_DATA (headerbuf) = (guint8 *) waveheader; - GST_BUFFER_SIZE (headerbuf) = headerlen; - - if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux), - headerbuf, &header, &extra)) { - gst_caps_unref (stream->caps); - stream->caps = gst_riff_create_audio_caps (header->format, NULL, - header, extra, NULL, NULL); - - if (extra) - gst_buffer_unref (extra); + if (waveheadernode) { + waveheader = (const guint8 *) waveheadernode->data; + headerlen = QT_UINT32 (waveheader); + + if (headerlen > 8) { + gst_riff_strf_auds *header = NULL; + GstBuffer *headerbuf; + GstBuffer *extra; + + waveheader += 8; + headerlen -= 8; + + headerbuf = gst_buffer_new (); + GST_BUFFER_DATA (headerbuf) = (guint8 *) waveheader; + GST_BUFFER_SIZE (headerbuf) = headerlen; + + if (gst_riff_parse_strf_auds (GST_ELEMENT_CAST (qtdemux), + headerbuf, &header, &extra)) { + gst_caps_unref (stream->caps); + stream->caps = gst_riff_create_audio_caps (header->format, NULL, + header, extra, NULL, NULL); + + if (extra) + gst_buffer_unref (extra); + } } - } + } else + GST_DEBUG ("Didn't find waveheadernode for this codec"); } g_node_destroy (wavenode); } -- 2.7.4