mirror of https://github.com/bjornbytes/lovr.git
Check shaderblock offset exists before reading. Prevents a segfault
This commit is contained in:
parent
ada79dbf5d
commit
0dcf86bc3d
|
@ -19,8 +19,9 @@ static int l_lovrShaderBlockGetSize(lua_State* L) {
|
||||||
|
|
||||||
static int l_lovrShaderBlockGetOffset(lua_State* L) {
|
static int l_lovrShaderBlockGetOffset(lua_State* L) {
|
||||||
ShaderBlock* block = luax_checktype(L, 1, ShaderBlock);
|
ShaderBlock* block = luax_checktype(L, 1, ShaderBlock);
|
||||||
const char* field = luaL_checkstring(L, 2);
|
const char* name = luaL_checkstring(L, 2);
|
||||||
const Uniform* uniform = lovrShaderBlockGetUniform(block, field);
|
const Uniform* uniform = lovrShaderBlockGetUniform(block, name);
|
||||||
|
lovrAssert(uniform, "Unknown uniform for ShaderBlock '%s'", name);
|
||||||
lua_pushinteger(L, uniform->offset);
|
lua_pushinteger(L, uniform->offset);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue