summaryrefslogtreecommitdiff
path: root/ext/smoothstreaming
diff options
context:
space:
mode:
authorThiago Santos <ts.santos@sisa.samsung.com>2013-12-17 17:55:58 -0300
committerThiago Santos <ts.santos@sisa.samsung.com>2013-12-18 18:52:19 -0300
commit628461b4d1df47aa6a208d48a6cce7ecf315d053 (patch)
tree820cd39050946d42edb99ab7996002d56c96ed03 /ext/smoothstreaming
parent5948a073244d868186840a37deb03b14a9eb77c9 (diff)
downloadgstreamer-plugins-bad-628461b4d1df47aa6a208d48a6cce7ecf315d053.tar.gz
mssdemux: fix segfault when trying to access codec_data
Check if codec_data was obtained before trying to use it to prevent a segfault
Diffstat (limited to 'ext/smoothstreaming')
-rw-r--r--ext/smoothstreaming/gstmssmanifest.c51
1 files changed, 27 insertions, 24 deletions
diff --git a/ext/smoothstreaming/gstmssmanifest.c b/ext/smoothstreaming/gstmssmanifest.c
index ab0dfd0fa..5582b0301 100644
--- a/ext/smoothstreaming/gstmssmanifest.c
+++ b/ext/smoothstreaming/gstmssmanifest.c
@@ -627,32 +627,35 @@ _gst_mss_stream_audio_caps_from_qualitylevel_xml (GstMssStreamQuality * q)
if (!codec_data) {
gint codec_data_len;
codec_data_str = (gchar *) xmlGetProp (node, (xmlChar *) "WaveFormatEx");
- codec_data_len = strlen (codec_data_str) / 2;
- /* a WAVEFORMATEX structure is 18 bytes */
- if (codec_data_str && codec_data_len >= 18) {
- GstMapInfo mapinfo;
- codec_data = gst_buffer_from_hex_string ((gchar *) codec_data_str);
-
- /* since this is a WAVEFORMATEX, try to get the block_align and rate */
- gst_buffer_map (codec_data, &mapinfo, GST_MAP_READ);
- if (!channels_str) {
- channels = GST_READ_UINT16_LE (mapinfo.data + 2);
- }
- if (!rate_str) {
- rate = GST_READ_UINT32_LE (mapinfo.data + 4);
- }
- if (!block_align) {
- block_align = GST_READ_UINT16_LE (mapinfo.data + 12);
+ if (codec_data_str != NULL) {
+ codec_data_len = strlen (codec_data_str) / 2;
+
+ /* a WAVEFORMATEX structure is 18 bytes */
+ if (codec_data_str && codec_data_len >= 18) {
+ GstMapInfo mapinfo;
+ codec_data = gst_buffer_from_hex_string ((gchar *) codec_data_str);
+
+ /* since this is a WAVEFORMATEX, try to get the block_align and rate */
+ gst_buffer_map (codec_data, &mapinfo, GST_MAP_READ);
+ if (!channels_str) {
+ channels = GST_READ_UINT16_LE (mapinfo.data + 2);
+ }
+ if (!rate_str) {
+ rate = GST_READ_UINT32_LE (mapinfo.data + 4);
+ }
+ if (!block_align) {
+ block_align = GST_READ_UINT16_LE (mapinfo.data + 12);
+ }
+ gst_buffer_unmap (codec_data, &mapinfo);
+
+ /* Consume all the WAVEFORMATEX structure, and pass only the rest of
+ * the data as the codec private data */
+ gst_buffer_resize (codec_data, 18, -1);
+ } else {
+ GST_WARNING ("Dropping WaveFormatEx: data is %d bytes, "
+ "but at least 18 bytes are expected", codec_data_len);
}
- gst_buffer_unmap (codec_data, &mapinfo);
-
- /* Consume all the WAVEFORMATEX structure, and pass only the rest of
- * the data as the codec private data */
- gst_buffer_resize (codec_data, 18, -1);
- } else {
- GST_WARNING ("Dropping WaveFormatEx: data is %d bytes, "
- "but at least 18 bytes are expected", codec_data_len);
}
}