Skip to content

Instantly share code, notes, and snippets.

@leper
Created April 7, 2012 13:21
Show Gist options
  • Save leper/2328847 to your computer and use it in GitHub Desktop.
Save leper/2328847 to your computer and use it in GitHub Desktop.
Fix crashes with empty script files
Index: source/lib/file/vfs/vfs.cpp
===================================================================
--- source/lib/file/vfs/vfs.cpp (revision 11448)
+++ source/lib/file/vfs/vfs.cpp (working copy)
@@ -1,4 +1,4 @@
-/* Copyright (c) 2010 Wildfire Games
+/* Copyright (c) 2012 Wildfire Games
*
* Permission is hereby granted, free of charge, to any person obtaining
* a copy of this software and associated documentation files (the
@@ -178,6 +178,13 @@
RETURN_STATUS_IF_ERR(file->Loader()->Load(file->Name(), fileContents, file->Size()));
}
}
+ else
+ {
+ // we reserve a cache of size 1 to allow loading of empty files
+ // (previosly such files caused crashed)
+ fileContents = m_fileCache.Reserve(1);
+ m_fileCache.Add(pathname, fileContents, 1);
+ }
}
stats_io_user_request(size);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment