[Mesa-dev] [PATCH] mesa: silence coverity warning in _mesa_get_attachment()
Brian Paul
brianp at vmware.com
Thu Aug 16 08:04:23 PDT 2012
The warning is kind of bogus since the i >= ctx->Const.MaxColorAttachments
will prevent out of bounds array accesses, but it's easily silenced.
See http://bugs.freedesktop.org/show_bug.cgi?id=53426
---
src/mesa/main/fbobject.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/src/mesa/main/fbobject.c b/src/mesa/main/fbobject.c
index aa8ba18..556426c 100644
--- a/src/mesa/main/fbobject.c
+++ b/src/mesa/main/fbobject.c
@@ -215,8 +215,9 @@ _mesa_get_attachment(struct gl_context *ctx, struct gl_framebuffer *fb,
* hardware is used.
*/
i = attachment - GL_COLOR_ATTACHMENT0_EXT;
- if (i >= ctx->Const.MaxColorAttachments
- || (i > 0 && ctx->API == API_OPENGLES)) {
+ if (i >= ctx->Const.MaxColorAttachments ||
+ i >= Elements(fb->Attachment) ||
+ (i > 0 && ctx->API == API_OPENGLES)) {
return NULL;
}
return &fb->Attachment[BUFFER_COLOR0 + i];
--
1.7.3.4
More information about the mesa-dev
mailing list