diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index f077d38f..8c538a7c 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -484,7 +484,7 @@ void FILESYSTEM_loadFileToMemory( handle = PHYSFS_openRead(name); if (handle == NULL) { - return; + goto fail; } length = PHYSFS_fileLength(handle); if (len != NULL) @@ -518,6 +518,17 @@ void FILESYSTEM_loadFileToMemory( FILESYSTEM_freeMemory(mem); } PHYSFS_close(handle); + return; + +fail: + if (mem != NULL) + { + *mem = NULL; + } + if (len != NULL) + { + *len = 0; + } } void FILESYSTEM_loadAssetToMemory( @@ -645,7 +656,7 @@ bool FILESYSTEM_saveTiXml2Document(const char *name, tinyxml2::XMLDocument& doc) bool FILESYSTEM_loadTiXml2Document(const char *name, tinyxml2::XMLDocument& doc) { /* XMLDocument.LoadFile doesn't account for Unicode paths, PHYSFS does */ - unsigned char *mem = NULL; + unsigned char *mem; FILESYSTEM_loadFileToMemory(name, &mem, NULL, true); if (mem == NULL) { diff --git a/desktop_version/src/Graphics.cpp b/desktop_version/src/Graphics.cpp index 92a41094..f2933c90 100644 --- a/desktop_version/src/Graphics.cpp +++ b/desktop_version/src/Graphics.cpp @@ -361,7 +361,7 @@ void Graphics::Makebfont(void) flipbfont.push_back(TempFlipped); }) - unsigned char* charmap = NULL; + unsigned char* charmap; size_t length; FILESYSTEM_loadAssetToMemory("graphics/font.txt", &charmap, &length, false); if (charmap != NULL) diff --git a/desktop_version/src/GraphicsResources.cpp b/desktop_version/src/GraphicsResources.cpp index 3558e391..acc1fa71 100644 --- a/desktop_version/src/GraphicsResources.cpp +++ b/desktop_version/src/GraphicsResources.cpp @@ -34,8 +34,8 @@ static SDL_Surface* LoadImage(const char *filename, bool noBlend = true, bool no unsigned char *data; unsigned int width, height; - unsigned char *fileIn = NULL; - size_t length = 0; + unsigned char *fileIn; + size_t length; FILESYSTEM_loadAssetToMemory(filename, &fileIn, &length, false); if (noAlpha) { diff --git a/desktop_version/src/Screen.cpp b/desktop_version/src/Screen.cpp index d32c394d..a232634e 100644 --- a/desktop_version/src/Screen.cpp +++ b/desktop_version/src/Screen.cpp @@ -127,8 +127,8 @@ void Screen::GetSettings(ScreenSettings* settings) void Screen::LoadIcon(void) { #ifndef __APPLE__ - unsigned char *fileIn = NULL; - size_t length = 0; + unsigned char *fileIn; + size_t length; unsigned char *data; unsigned int width, height; FILESYSTEM_loadAssetToMemory("VVVVVV.png", &fileIn, &length, false); diff --git a/desktop_version/src/SoundSystem.cpp b/desktop_version/src/SoundSystem.cpp index c0b79fad..e5d0ead8 100644 --- a/desktop_version/src/SoundSystem.cpp +++ b/desktop_version/src/SoundSystem.cpp @@ -30,7 +30,7 @@ MusicTrack::MusicTrack(SDL_RWops *rw) SoundTrack::SoundTrack(const char* fileName) { unsigned char *mem; - size_t length = 0; + size_t length; sound = NULL; diff --git a/desktop_version/src/editor.cpp b/desktop_version/src/editor.cpp index 88a53c63..6b2e0725 100644 --- a/desktop_version/src/editor.cpp +++ b/desktop_version/src/editor.cpp @@ -248,7 +248,7 @@ void editorclass::getDirectoryData(void) } bool editorclass::getLevelMetaData(std::string& _path, LevelMetaData& _data ) { - unsigned char *uMem = NULL; + unsigned char *uMem; FILESYSTEM_loadFileToMemory(_path.c_str(), &uMem, NULL, true); if (uMem == NULL)