From f5a9f5e221eaaf90e19d3f45ede5ab80fd5e84b5 Mon Sep 17 00:00:00 2001 From: Vincent Penquerc'h Date: Fri, 2 May 2014 11:20:33 +0100 Subject: [PATCH] matroska: catch failure to map buffer Avoids dereferencing NULL. Coverity 1139712 --- gst/matroska/ebml-write.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/gst/matroska/ebml-write.c b/gst/matroska/ebml-write.c index 4596c2f200..d39a23adbf 100644 --- a/gst/matroska/ebml-write.c +++ b/gst/matroska/ebml-write.c @@ -427,7 +427,10 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf, gst_buffer_map (buf, &map, GST_MAP_READ); buf_data = map.data; } - if (!gst_byte_writer_put_data (ebml->streamheader, buf_data, data_size)) + if (!buf_data) + GST_WARNING ("Failed to map buffer"); + else if (!gst_byte_writer_put_data (ebml->streamheader, buf_data, + data_size)) GST_WARNING ("Error writing data to streamheader"); } if (ebml->cache) { @@ -435,7 +438,9 @@ gst_ebml_write_element_push (GstEbmlWrite * ebml, GstBuffer * buf, gst_buffer_map (buf, &map, GST_MAP_READ); buf_data = map.data; } - if (!gst_byte_writer_put_data (ebml->cache, buf_data, data_size)) + if (!buf_data) + GST_WARNING ("Failed to map buffer"); + else if (!gst_byte_writer_put_data (ebml->cache, buf_data, data_size)) GST_WARNING ("Error writing data to cache"); if (map.data) gst_buffer_unmap (buf, &map); -- 2.34.1