Fix out-of-bounds reads on GL_BGRA colours

This commit is contained in:
Luke Benstead 2021-04-07 20:30:55 +01:00
parent 89031cfaba
commit b61d9a157b

View File

@ -693,7 +693,8 @@ GL_FORCE_INLINE void _readNormalData(const GLuint first, const GLuint count, Ver
}
GL_FORCE_INLINE void _readDiffuseData(const GLuint first, const GLuint count, Vertex* output) {
const GLuint cstride = (DIFFUSE_POINTER.stride) ? DIFFUSE_POINTER.stride : DIFFUSE_POINTER.size * byte_size(DIFFUSE_POINTER.type);
const GLuint size = (DIFFUSE_POINTER.size == GL_BGRA) ? 4 : DIFFUSE_POINTER.size;
const GLuint cstride = (DIFFUSE_POINTER.stride) ? DIFFUSE_POINTER.stride : size * byte_size(DIFFUSE_POINTER.type);
const GLubyte* cptr = ((GLubyte*) DIFFUSE_POINTER.ptr) + (first * cstride);
ReadDiffuseFunc func = calcReadDiffuseFunc();