summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2014-08-19 07:51:07 -0600
committerEmil Velikov <emil.l.velikov@gmail.com>2014-08-27 13:38:29 +0100
commit6f8d2db2ef9f9d33039ef01206417d6c5a1f01a1 (patch)
tree90713c82fd93cc479838bc252a2ff60a8bb4ee92 /src
parent0374fdd5b6f70af36fca92abae5d8166e93d6372 (diff)
mesa: fix NULL pointer deref bug in _mesa_drawbuffers()
This is a follow-on fix to commit 39b40ad144. Fixes a crash if the user calls glDrawBuffers(0, NULL). Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=82814 Cc: "10.2" <mesa-stable@lists.freedesktop.org> Reviewed-by: Roland Scheidegger <sroland@vmware.com> (cherry picked from commit 31ce84a81f7166ded07e9cb41e5dfe212dd8fed1)
Diffstat (limited to 'src')
-rw-r--r--src/mesa/main/buffers.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/mesa/main/buffers.c b/src/mesa/main/buffers.c
index 6b4fac9f58d..f8c15583e0b 100644
--- a/src/mesa/main/buffers.c
+++ b/src/mesa/main/buffers.c
@@ -498,7 +498,7 @@ _mesa_drawbuffers(struct gl_context *ctx, GLuint n, const GLenum *buffers,
* (ex: glDrawBuffer(GL_FRONT_AND_BACK)).
* Otherwise, destMask[x] can only have one bit set.
*/
- if (_mesa_bitcount(destMask[0]) > 1) {
+ if (n > 0 && _mesa_bitcount(destMask[0]) > 1) {
GLuint count = 0, destMask0 = destMask[0];
while (destMask0) {
GLint bufIndex = ffs(destMask0) - 1;