Browse Source

Fix File:getSize crashing for a non-existent file

Bart van Strien 14 years ago
parent
commit
fdc56e7e73
2 changed files with 9 additions and 1 deletions
  1. 1 0
      changes.txt
  2. 8 1
      src/modules/filesystem/physfs/wrap_File.cpp

+ 1 - 0
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.
 

+ 8 - 1
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;
 	}