From 56b870e44106188f425df6eb45b7a394f0420e5e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Wed, 23 Nov 2011 15:33:46 -0700 Subject: mesa: check for null ptr in _mesa_is_bufferobj() This simplifies a few callers. And it adds a bit of robustness. Reviewed-by: Kenneth Graunke Reviewed-by: Yuanhan Liu --- src/mesa/main/bufferobj.c | 6 +++--- src/mesa/main/bufferobj.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) (limited to 'src/mesa/main') diff --git a/src/mesa/main/bufferobj.c b/src/mesa/main/bufferobj.c index 4c77397d9dc..8e8fcd59548 100644 --- a/src/mesa/main/bufferobj.c +++ b/src/mesa/main/bufferobj.c @@ -1286,14 +1286,14 @@ _mesa_CopyBufferSubData(GLenum readTarget, GLenum writeTarget, ASSERT_OUTSIDE_BEGIN_END(ctx); src = get_buffer(ctx, readTarget); - if (!src || !_mesa_is_bufferobj(src)) { + if (!_mesa_is_bufferobj(src)) { _mesa_error(ctx, GL_INVALID_ENUM, "glCopyBuffserSubData(readTarget = 0x%x)", readTarget); return; } dst = get_buffer(ctx, writeTarget); - if (!dst || !_mesa_is_bufferobj(dst)) { + if (!_mesa_is_bufferobj(dst)) { _mesa_error(ctx, GL_INVALID_ENUM, "glCopyBuffserSubData(writeTarget = 0x%x)", writeTarget); return; @@ -1421,7 +1421,7 @@ _mesa_MapBufferRange(GLenum target, GLintptr offset, GLsizeiptr length, } bufObj = get_buffer(ctx, target); - if (!bufObj || !_mesa_is_bufferobj(bufObj)) { + if (!_mesa_is_bufferobj(bufObj)) { _mesa_error(ctx, GL_INVALID_ENUM, "glMapBufferRange(target = 0x%x)", target); return NULL; diff --git a/src/mesa/main/bufferobj.h b/src/mesa/main/bufferobj.h index b4e70f2f08a..c0d5a641a46 100644 --- a/src/mesa/main/bufferobj.h +++ b/src/mesa/main/bufferobj.h @@ -53,7 +53,7 @@ _mesa_bufferobj_mapped(const struct gl_buffer_object *obj) static inline GLboolean _mesa_is_bufferobj(const struct gl_buffer_object *obj) { - return obj->Name != 0; + return obj != NULL && obj->Name != 0; } -- cgit v1.2.3