dmabuf: handle mmap failure

Otherwise gstreamer may segfault trying to access MAP_FAILED.

https://bugzilla.gnome.org/show_bug.cgi?id=699470
This commit is contained in:
Michael Olbrich 2013-05-02 15:37:14 +02:00 committed by Sebastian Dröge
parent f9befdecfe
commit 347898d516

View file

@ -96,8 +96,15 @@ gst_dmabuf_mem_map (GstMemory * gmem, gsize maxsize, GstMapFlags flags)
goto out; goto out;
} }
if (mem->fd != -1) if (mem->fd != -1) {
mem->data = mmap (0, maxsize, prot, MAP_SHARED, mem->fd, 0); mem->data = mmap (0, maxsize, prot, MAP_SHARED, mem->fd, 0);
if (mem->data == MAP_FAILED) {
mem->data = NULL;
GST_ERROR ("%p: fd %d: mmap failed: %s", mem, mem->fd,
g_strerror(errno));
goto out;
}
}
GST_DEBUG ("%p: fd %d: mapped %p", mem, mem->fd, mem->data); GST_DEBUG ("%p: fd %d: mapped %p", mem, mem->fd, mem->data);