summaryrefslogtreecommitdiffstats
path: root/src/mesa
diff options
context:
space:
mode:
authorBrian <[email protected]>2007-08-23 21:39:51 +0100
committerBrian <[email protected]>2007-08-23 21:39:51 +0100
commitac8249d0ed382c547a2219449fa6dea328b19193 (patch)
tree8214195e47a2e60c6ee0d1495277b1322bdeef58 /src/mesa
parent440e794b05511c1854c22956e6e306d1b1d8682d (diff)
check for null ptr in xm_buffer_unreference()
Diffstat (limited to 'src/mesa')
-rw-r--r--src/mesa/drivers/x11/xm_softpipe.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/mesa/drivers/x11/xm_softpipe.c b/src/mesa/drivers/x11/xm_softpipe.c
index 432f306e94e..ff33ad78509 100644
--- a/src/mesa/drivers/x11/xm_softpipe.c
+++ b/src/mesa/drivers/x11/xm_softpipe.c
@@ -112,17 +112,19 @@ xm_buffer_reference(struct pipe_winsys *pws, struct pipe_buffer_handle *buf)
static void
xm_buffer_unreference(struct pipe_winsys *pws, struct pipe_buffer_handle **buf)
{
- struct xm_buffer *xm_buf = xm_bo(*buf);
- xm_buf->refcount--;
- assert(xm_buf->refcount >= 0);
- if (xm_buf->refcount == 0) {
- if (xm_buf->data) {
- free(xm_buf->data);
- xm_buf->data = NULL;
+ if (*buf) {
+ struct xm_buffer *xm_buf = xm_bo(*buf);
+ xm_buf->refcount--;
+ assert(xm_buf->refcount >= 0);
+ if (xm_buf->refcount == 0) {
+ if (xm_buf->data) {
+ free(xm_buf->data);
+ xm_buf->data = NULL;
+ }
+ free(xm_buf);
}
- free(xm_buf);
+ *buf = NULL;
}
- *buf = NULL;
}
static void