]> git.tdb.fi Git - libs/gl.git/commitdiff
Guard against hitting the end of the array in get_gl_type
authorMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 19:58:51 +0000 (22:58 +0300)
committerMikko Rasa <tdb@tdb.fi>
Sat, 3 Apr 2021 21:33:21 +0000 (00:33 +0300)
source/core/datatype.cpp

index af7446eb1f86916e23af1c2c84cd4e57c7fcf3ca..4dd0b89fc2f8a2e7bd6c86bd75e9fd3465c4cbc3 100644 (file)
@@ -88,8 +88,9 @@ namespace GL {
 
 GLenum get_gl_type(DataType type)
 {
-       const MappedType *ptr = lower_bound(type_map, type_map+type_map_size, type, type_compare);
-       if(ptr->type!=type)
+       const MappedType *end = type_map+type_map_size;
+       const MappedType *ptr = lower_bound(type_map, end, type, type_compare);
+       if(ptr==end || ptr->type!=type)
                throw invalid_argument("get_gl_type");
        return ptr->gl_type;
 }