From bb46fa5745d3555e1ecfbe8ea34e32d513324f17 Mon Sep 17 00:00:00 2001 From: bjorn Date: Sun, 4 Dec 2022 17:59:22 -0800 Subject: [PATCH] Pass:line copies tables of vectors to vertices better; Using vec3_init writes 4 floats which can, extremely rarely, go past the end of the vertex buffer. --- src/api/l_graphics_pass.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/api/l_graphics_pass.c b/src/api/l_graphics_pass.c index 4996e104..bd165122 100644 --- a/src/api/l_graphics_pass.c +++ b/src/api/l_graphics_pass.c @@ -558,9 +558,10 @@ static void luax_readvertices(lua_State* L, int index, float* vertices, uint32_t } else if (innerType == LUA_TUSERDATA || innerType == LUA_TLIGHTUSERDATA) { for (uint32_t i = 0; i < count; i++) { lua_rawgeti(L, index, i + 1); - vec3_init(vertices, luax_checkvector(L, -1, V_VEC3, NULL)); - lua_pop(L, 1); + float* v = luax_checkvector(L, -1, V_VEC3, NULL); + memcpy(vertices, v, 3 * sizeof(float)); vertices += 3; + lua_pop(L, 1); } } break;