Error in setVertices when overflowing Mesh size;

This commit is contained in:
bjorn 2017-03-23 17:49:57 -07:00
parent 7077d89a22
commit 2ae10967c4
1 changed files with 5 additions and 0 deletions

View File

@ -213,6 +213,11 @@ int l_lovrMeshSetVertices(lua_State* L) {
luaL_checktype(L, 2, LUA_TTABLE);
int vertexCount = lua_objlen(L, 2);
int start = luaL_optnumber(L, 3, 1) - 1;
int maxVertices = lovrMeshGetVertexCount(mesh);
if (start + vertexCount > maxVertices) {
return luaL_error(L, "Mesh can only hold %d vertices", maxVertices);
}
void* vertices = lovrMeshMap(mesh, start, vertexCount);
char* vertex = vertices;