From: Mikko Rasa Date: Sat, 3 Apr 2021 19:58:51 +0000 (+0300) Subject: Guard against hitting the end of the array in get_gl_type X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=26634147dfbb5be9a4046a0d50b3b1d6857ad68d;p=libs%2Fgl.git Guard against hitting the end of the array in get_gl_type --- diff --git a/source/core/datatype.cpp b/source/core/datatype.cpp index af7446eb..4dd0b89f 100644 --- a/source/core/datatype.cpp +++ b/source/core/datatype.cpp @@ -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; }