Fix out of bounds read

This commit is contained in:
Luke Benstead 2020-02-29 09:47:58 +00:00
parent 43a8db9e9d
commit 937ad56c26
3 changed files with 7 additions and 2 deletions

View File

@ -634,7 +634,7 @@ void APIENTRY glGetIntegerv(GLenum pname, GLint *params) {
*params = MAX_LIGHTS;
break;
case GL_TEXTURE_BINDING_2D:
*params = _glGetBoundTexture()->index;
*params = (_glGetBoundTexture()) ? _glGetBoundTexture()->index : 0;
break;
case GL_DEPTH_FUNC:
*params = DEPTH_FUNC;

View File

@ -371,7 +371,9 @@ void APIENTRY glDeleteTextures(GLsizei n, GLuint *textures) {
txr->palette = NULL;
}
named_array_release(&TEXTURE_OBJECTS, *textures++);
named_array_release(&TEXTURE_OBJECTS, *textures);
*textures = 0;
textures++;
}
}

View File

@ -34,6 +34,9 @@ char named_array_used(NamedArray* array, unsigned int id) {
unsigned int i = id / 8;
unsigned int j = id % 8;
assert(i < array->max_element_count);
assert(array->used_markers);
unsigned char v = array->used_markers[i] & (unsigned char) (1 << j);
return !!(v);
}