From 6b7bad5385c63da526a412757074e7d81af27c15 Mon Sep 17 00:00:00 2001 From: Matthias Braun Date: Wed, 31 Jan 2007 16:23:38 +0000 Subject: [PATCH] physfs seems buggy and allows opening empty filename, catch this case SVN-Revision: 4757 --- src/physfs/physfs_sdl.cpp | 6 ++++++ src/physfs/physfs_stream.cpp | 5 +++++ 2 files changed, 11 insertions(+) diff --git a/src/physfs/physfs_sdl.cpp b/src/physfs/physfs_sdl.cpp index 5ac130814..0d6730b4d 100644 --- a/src/physfs/physfs_sdl.cpp +++ b/src/physfs/physfs_sdl.cpp @@ -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: emtpy filename"); + } + PHYSFS_file* file = (PHYSFS_file*) PHYSFS_openRead(filename.c_str()); if(!file) { std::stringstream msg; diff --git a/src/physfs/physfs_stream.cpp b/src/physfs/physfs_stream.cpp index 70175ed07..1bc8d50e6 100644 --- a/src/physfs/physfs_stream.cpp +++ b/src/physfs/physfs_stream.cpp @@ -28,6 +28,11 @@ IFileStreambuf::IFileStreambuf(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: emtpy filename"); + } file = PHYSFS_openRead(filename.c_str()); if(file == 0) { std::stringstream msg; -- 2.11.0