diff --git a/src/lua_colorlib.c b/src/lua_colorlib.c index bf9c33886..d334052ab 100644 --- a/src/lua_colorlib.c +++ b/src/lua_colorlib.c @@ -116,6 +116,9 @@ static int extracolormap_get(lua_State *L) extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP)); enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt); + if (!exc) + return LUA_ErrInvalid(L, "extracolormap_t"); + switch (field) { case extracolormap_red: @@ -198,6 +201,9 @@ static int extracolormap_set(lua_State *L) extracolormap_t *exc = *((extracolormap_t **)luaL_checkudata(L, 1, META_EXTRACOLORMAP)); enum extracolormap_e field = luaL_checkoption(L, 2, NULL, extracolormap_opt); + if (!exc) + return LUA_ErrInvalid(L, "extracolormap_t"); + UINT8 r = R_GetRgbaR(exc->rgba); UINT8 g = R_GetRgbaG(exc->rgba); UINT8 b = R_GetRgbaB(exc->rgba); diff --git a/src/lua_script.c b/src/lua_script.c index b0b6eeec7..c63905d04 100644 --- a/src/lua_script.c +++ b/src/lua_script.c @@ -892,6 +892,8 @@ void LUA_InvalidateLevel(void) LUA_InvalidateUserdata(§ors[i]); LUA_InvalidateUserdata(§ors[i].lines); LUA_InvalidateUserdata(§ors[i].tags); + if (sectors[i].extra_colormap) + LUA_InvalidateUserdata(sectors[i].extra_colormap); if (sectors[i].ffloors) { for (rover = sectors[i].ffloors; rover; rover = rover->next)