From fdc56e7e73e964d18381067803e8b1a073c510fe Mon Sep 17 00:00:00 2001 From: Bart van Strien Date: Sat, 6 Aug 2011 14:44:49 +0200 Subject: [PATCH] Fix File:getSize crashing for a non-existent file --- changes.txt | 1 + src/modules/filesystem/physfs/wrap_File.cpp | 9 ++++++++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/changes.txt b/changes.txt index af28d43b4..21d59c7bf 100644 --- a/changes.txt +++ b/changes.txt @@ -37,6 +37,7 @@ LOVE 0.8.0 [Rubber Piggy] * Fixed love.filesystem.lines() leaking. * Fixed Source controls inconsistencies. * Fixed most leaking on unclosed File objects. + * Fixed crash when File:getSize() was called on a non-existent file. * Renamed SpriteBatch's lock/unlock to bind/unbind. diff --git a/src/modules/filesystem/physfs/wrap_File.cpp b/src/modules/filesystem/physfs/wrap_File.cpp index f8649b31a..437dcc5f4 100644 --- a/src/modules/filesystem/physfs/wrap_File.cpp +++ b/src/modules/filesystem/physfs/wrap_File.cpp @@ -37,7 +37,14 @@ namespace physfs int w_File_getSize(lua_State * L) { File * t = luax_checkfile(L, 1); - lua_pushinteger(L, t->getSize()); + try + { + lua_pushinteger(L, t->getSize()); + } + catch (Exception & e) + { + return luaL_error(L, e.what()); + } return 1; }