summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2008-04-27 21:19:34 +0900
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2008-04-27 21:19:34 +0900
commit083008d808c02226a3dfead6000a84efd5e6a9fa (patch)
treea10cfe9f7742e6044b6d1fed7185541d3100046d /src
parente3c415995706d2dda7c34a227e2e24d0745763ec (diff)
pipebuffer: Be extra cautious with the incoming buffers.
A common mistake is trying to fence user or malloc buffers. So don't let the crash happen inside pipebuffer lib.
Diffstat (limited to 'src')
-rw-r--r--src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c20
1 files changed, 17 insertions, 3 deletions
diff --git a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
index d3c1ec4fbe..a92daf91dd 100644
--- a/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
+++ b/src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c
@@ -356,11 +356,25 @@ void
buffer_fence(struct pb_buffer *buf,
struct pipe_fence_handle *fence)
{
- struct fenced_buffer *fenced_buf = fenced_buffer(buf);
- struct fenced_buffer_list *fenced_list = fenced_buf->list;
- struct pipe_winsys *winsys = fenced_list->winsys;
+ struct fenced_buffer *fenced_buf;
+ struct fenced_buffer_list *fenced_list;
+ struct pipe_winsys *winsys;
/* FIXME: receive this as a parameter */
unsigned flags = fence ? PIPE_BUFFER_USAGE_GPU_READ_WRITE : 0;
+
+ /* This is a public function, so be extra cautious with the buffer passed,
+ * as happens frequently to receive null buffers, or pointer to buffers
+ * other than fenced buffers. */
+ assert(buf);
+ if(!buf)
+ return;
+ assert(buf->vtbl == &fenced_buffer_vtbl);
+ if(buf->vtbl != &fenced_buffer_vtbl)
+ return;
+
+ fenced_buf = fenced_buffer(buf);
+ fenced_list = fenced_buf->list;
+ winsys = fenced_list->winsys;
if(fence == fenced_buf->fence) {
/* Handle the same fence case specially, not only because it is a fast