]> git.tdb.fi Git - libs/gl.git/blobdiff - source/core/datatype.cpp
Guard against hitting the end of the array in get_gl_type
[libs/gl.git] / 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;
 }