summaryrefslogtreecommitdiff
path: root/plugins
diff options
context:
space:
mode:
authorEdward Hervey <edward@collabora.com>2014-04-16 11:39:15 +0200
committerEdward Hervey <bilboed@bilboed.com>2016-02-23 17:30:45 +0100
commit555df9d614149fa0a094c14788b61e16a439b3f8 (patch)
tree407a84fbf0280f0b41ddabcb040b2dfdb5446b0f /plugins
parentf7cba27157f9e36c34bda2d8741be4ccb2d17d96 (diff)
plugins: Check return values of gst_buffer_map()
They can fail for various reasons. For non-fatal cases (such as the dump feature of identiy and fakesink), we just silently skip it. For other cases post an error message. https://bugzilla.gnome.org/show_bug.cgi?id=728326
Diffstat (limited to 'plugins')
-rw-r--r--plugins/elements/gstfakesink.c7
-rw-r--r--plugins/elements/gstfakesrc.c27
-rw-r--r--plugins/elements/gstfdsrc.c9
-rw-r--r--plugins/elements/gstfilesrc.c8
-rw-r--r--plugins/elements/gstidentity.c7
-rw-r--r--plugins/elements/gstqueue2.c20
6 files changed, 64 insertions, 14 deletions
diff --git a/plugins/elements/gstfakesink.c b/plugins/elements/gstfakesink.c
index 8a1d1da01..2c6fdcbee 100644
--- a/plugins/elements/gstfakesink.c
+++ b/plugins/elements/gstfakesink.c
@@ -479,9 +479,10 @@ gst_fake_sink_render (GstBaseSink * bsink, GstBuffer * buf)
if (sink->dump) {
GstMapInfo info;
- gst_buffer_map (buf, &info, GST_MAP_READ);
- gst_util_dump_mem (info.data, info.size);
- gst_buffer_unmap (buf, &info);
+ if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
+ gst_util_dump_mem (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
+ }
}
if (sink->num_buffers_left == 0)
goto eos;
diff --git a/plugins/elements/gstfakesrc.c b/plugins/elements/gstfakesrc.c
index 50fad8ef0..5376ccb7a 100644
--- a/plugins/elements/gstfakesrc.c
+++ b/plugins/elements/gstfakesrc.c
@@ -716,7 +716,10 @@ gst_fake_src_create_buffer (GstFakeSrc * src, gsize * bufsize)
/* try again (this will allocate a new parent) */
return gst_fake_src_create_buffer (src, bufsize);
}
- gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ if (buf == NULL)
+ goto buffer_create_fail;
+ if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+ goto buffer_write_fail;
gst_fake_src_prepare_buffer (src, info.data, info.size);
gst_buffer_unmap (buf, &info);
break;
@@ -726,12 +729,28 @@ gst_fake_src_create_buffer (GstFakeSrc * src, gsize * bufsize)
break;
}
if (dump) {
- gst_buffer_map (buf, &info, GST_MAP_READ);
- gst_util_dump_mem (info.data, info.size);
- gst_buffer_unmap (buf, &info);
+ if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
+ gst_util_dump_mem (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
+ }
}
return buf;
+
+buffer_create_fail:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, BUSY, (NULL),
+ ("Failed to create a buffer"));
+ return NULL;
+ }
+
+buffer_write_fail:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, WRITE, (NULL),
+ ("Failed to write to buffer"));
+ gst_buffer_unref (buf);
+ return NULL;
+ }
}
static void
diff --git a/plugins/elements/gstfdsrc.c b/plugins/elements/gstfdsrc.c
index 8a5990745..28156b286 100644
--- a/plugins/elements/gstfdsrc.c
+++ b/plugins/elements/gstfdsrc.c
@@ -446,7 +446,8 @@ gst_fd_src_create (GstPushSrc * psrc, GstBuffer ** outbuf)
if (G_UNLIKELY (buf == NULL))
goto alloc_failed;
- gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+ goto buffer_read_error;
do {
readbytes = read (src->fd, info.data, blocksize);
@@ -508,6 +509,12 @@ read_error:
gst_buffer_unref (buf);
return GST_FLOW_ERROR;
}
+buffer_read_error:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, WRITE, (NULL), ("Can't write to buffer"));
+ gst_buffer_unref (buf);
+ return GST_FLOW_ERROR;
+ }
}
static gboolean
diff --git a/plugins/elements/gstfilesrc.c b/plugins/elements/gstfilesrc.c
index 27ec84bf9..117ded663 100644
--- a/plugins/elements/gstfilesrc.c
+++ b/plugins/elements/gstfilesrc.c
@@ -350,7 +350,8 @@ gst_file_src_fill (GstBaseSrc * basesrc, guint64 offset, guint length,
src->read_position = offset;
}
- gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+ goto buffer_write_fail;
data = info.data;
bytes_read = 0;
@@ -409,6 +410,11 @@ eos:
gst_buffer_resize (buf, 0, 0);
return GST_FLOW_EOS;
}
+buffer_write_fail:
+ {
+ GST_ELEMENT_ERROR (src, RESOURCE, WRITE, (NULL), ("Can't write to buffer"));
+ return GST_FLOW_ERROR;
+ }
}
static gboolean
diff --git a/plugins/elements/gstidentity.c b/plugins/elements/gstidentity.c
index f0e983307..a57999d94 100644
--- a/plugins/elements/gstidentity.c
+++ b/plugins/elements/gstidentity.c
@@ -603,9 +603,10 @@ gst_identity_transform_ip (GstBaseTransform * trans, GstBuffer * buf)
if (identity->dump) {
GstMapInfo info;
- gst_buffer_map (buf, &info, GST_MAP_READ);
- gst_util_dump_mem (info.data, info.size);
- gst_buffer_unmap (buf, &info);
+ if (gst_buffer_map (buf, &info, GST_MAP_READ)) {
+ gst_util_dump_mem (info.data, info.size);
+ gst_buffer_unmap (buf, &info);
+ }
}
if (!identity->silent) {
diff --git a/plugins/elements/gstqueue2.c b/plugins/elements/gstqueue2.c
index 116eaef3f..67e3f277f 100644
--- a/plugins/elements/gstqueue2.c
+++ b/plugins/elements/gstqueue2.c
@@ -1382,7 +1382,8 @@ gst_queue2_create_read (GstQueue2 * queue, guint64 offset, guint length,
else
buf = *buffer;
- gst_buffer_map (buf, &info, GST_MAP_WRITE);
+ if (!gst_buffer_map (buf, &info, GST_MAP_WRITE))
+ goto buffer_write_fail;
data = info.data;
GST_DEBUG_OBJECT (queue, "Reading %u bytes from %" G_GUINT64_FORMAT, length,
@@ -1533,6 +1534,14 @@ read_error:
gst_buffer_unref (buf);
return ret;
}
+buffer_write_fail:
+ {
+ GST_ELEMENT_ERROR (queue, RESOURCE, WRITE, (NULL),
+ ("Can't write to buffer"));
+ if (*buffer == NULL)
+ gst_buffer_unref (buf);
+ return GST_FLOW_ERROR;
+ }
}
/* should be called with QUEUE_LOCK */
@@ -1784,7 +1793,8 @@ gst_queue2_create_write (GstQueue2 * queue, GstBuffer * buffer)
ring_buffer = queue->ring_buffer;
rb_size = queue->ring_buffer_max_size;
- gst_buffer_map (buffer, &info, GST_MAP_READ);
+ if (!gst_buffer_map (buffer, &info, GST_MAP_READ))
+ goto buffer_read_error;
size = info.size;
data = info.data;
@@ -2060,6 +2070,12 @@ handle_error:
gst_buffer_unmap (buffer, &info);
return FALSE;
}
+buffer_read_error:
+ {
+ GST_ELEMENT_ERROR (queue, RESOURCE, READ, (NULL),
+ ("Can't read from buffer"));
+ return FALSE;
+ }
}
static gboolean