Explorar o código

Made type checking for love objects slightly more robust.

LÖVE should now cause an error instead of a crash when a Lua io file is passed into an argument expecting a love object.
Alex Szpakowski %!s(int64=10) %!d(string=hai) anos
pai
achega
cabf6dcae2
Modificáronse 1 ficheiros con 5 adicións e 1 borrados
  1. 5 1
      src/common/runtime.cpp

+ 5 - 1
src/common/runtime.cpp

@@ -465,7 +465,11 @@ bool luax_istype(lua_State *L, int idx, love::Type type)
 		return false;
 		return false;
 
 
 	Proxy *p = (Proxy *) lua_touserdata(L, idx);
 	Proxy *p = (Proxy *) lua_touserdata(L, idx);
-	return typeFlags[p->type][type];
+
+	if (p->type > INVALID_ID && p->type < TYPE_MAX_ENUM)
+		return typeFlags[p->type][type];
+	else
+		return false;
 }
 }
 
 
 int luax_getfunction(lua_State *L, const char *mod, const char *fn)
 int luax_getfunction(lua_State *L, const char *mod, const char *fn)