From cabf6dcae2f4b375a9c124e845fc0314ed982ef1 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 14 Dec 2015 18:30:43 -0400 Subject: [PATCH] Made type checking for love objects slightly more robust. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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. --- src/common/runtime.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/common/runtime.cpp b/src/common/runtime.cpp index dca9bb2df..a2a70cfd4 100644 --- a/src/common/runtime.cpp +++ b/src/common/runtime.cpp @@ -465,7 +465,11 @@ bool luax_istype(lua_State *L, int idx, love::Type type) return false; 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)