ColorDrawBuffer is an array of MAX_DRAW_BUFFERS == 8.
Found by Coverity.
Signed-off-by: Marcin Ślusarz <marcin.slusarz@intel.com>
Fixes: 7534c536ca0 ("mesa: add EXT_dsa (Named)Framebuffer functions")
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6067>
*param = fb->ColorReadBuffer;
}
else if (GL_DRAW_BUFFER0 <= pname && pname <= GL_DRAW_BUFFER15) {
- *param = fb->ColorDrawBuffer[pname - GL_DRAW_BUFFER0];
+ unsigned buffer = pname - GL_DRAW_BUFFER0;
+ if (buffer < ARRAY_SIZE(fb->ColorDrawBuffer))
+ *param = fb->ColorDrawBuffer[buffer];
+ else
+ _mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferParameterivEXT(pname)");
}
else {
_mesa_error(ctx, GL_INVALID_ENUM, "glGetFramebufferParameterivEXT(pname)");