diff options
author | José Fonseca <[email protected]> | 2008-04-27 21:19:34 +0900 |
---|---|---|
committer | José Fonseca <[email protected]> | 2008-04-27 21:19:34 +0900 |
commit | 083008d808c02226a3dfead6000a84efd5e6a9fa (patch) | |
tree | a10cfe9f7742e6044b6d1fed7185541d3100046d | |
parent | e3c415995706d2dda7c34a227e2e24d0745763ec (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.
-rw-r--r-- | src/gallium/auxiliary/pipebuffer/pb_buffer_fenced.c | 20 |
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 d3c1ec4fbea..a92daf91dd7 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 |