X-Git-Url: https://git.verplant.org/?a=blobdiff_plain;f=src%2Fphysfs%2Fphysfs_sdl.cpp;h=9fa1ccda95f2d989e688a268232ec949ee29acf8;hb=755ac9ae45065248ddf1343a82671f871b447577;hp=2a22af6bdbe79278fea04d61f50c5ddcd9f82a1c;hpb=07ddaed2a657e4d2a3d038fed223fc5827159caf;p=supertux.git diff --git a/src/physfs/physfs_sdl.cpp b/src/physfs/physfs_sdl.cpp index 2a22af6bd..9fa1ccda9 100644 --- a/src/physfs/physfs_sdl.cpp +++ b/src/physfs/physfs_sdl.cpp @@ -68,7 +68,7 @@ static int funcRead(struct SDL_RWops* context, void* ptr, int size, int maxnum) static int funcClose(struct SDL_RWops* context) { PHYSFS_file* file = (PHYSFS_file*) context->hidden.unknown.data1; - + PHYSFS_close(file); delete context; @@ -77,6 +77,12 @@ static int funcClose(struct SDL_RWops* context) SDL_RWops* get_physfs_SDLRWops(const std::string& filename) { + // check this as PHYSFS seems to be buggy and still returns a + // valid pointer in this case + if(filename == "") { + throw std::runtime_error("Couldn't open file: empty filename"); + } + PHYSFS_file* file = (PHYSFS_file*) PHYSFS_openRead(filename.c_str()); if(!file) { std::stringstream msg; @@ -84,7 +90,7 @@ SDL_RWops* get_physfs_SDLRWops(const std::string& filename) << PHYSFS_getLastError(); throw std::runtime_error(msg.str()); } - + SDL_RWops* ops = new SDL_RWops(); ops->type = 0; ops->hidden.unknown.data1 = file;