From 9fa5af5fbf2cb52bc25f5e90fdc650e040c50096 Mon Sep 17 00:00:00 2001 From: Ykkrosh Date: Thu, 19 Aug 2010 21:58:27 +0000 Subject: [PATCH] Avoid crash when loading texture named "". Report texture-loading errors. This was SVN commit r8006. --- source/lib/file/vfs/vfs_lookup.cpp | 7 ++++++- source/lib/res/graphics/ogl_tex.cpp | 8 +++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/source/lib/file/vfs/vfs_lookup.cpp b/source/lib/file/vfs/vfs_lookup.cpp index e6608f4120..011055848a 100644 --- a/source/lib/file/vfs/vfs_lookup.cpp +++ b/source/lib/file/vfs/vfs_lookup.cpp @@ -50,7 +50,12 @@ LibError vfs_Lookup(const VfsPath& pathname, VfsDirectory* startDirectory, VfsDi // early-out for pathname == "" when mounting into VFS root if(pathname.empty()) // (prevent iterator error in loop end condition) - return INFO::OK; + { + if(pfile) // preserve a guarantee that if pfile then we either return an error or set *pfile + return ERR::VFS_FILE_NOT_FOUND; + else + return INFO::OK; + } // for each directory component: VfsPath::iterator it; // (used outside of loop to get filename) diff --git a/source/lib/res/graphics/ogl_tex.cpp b/source/lib/res/graphics/ogl_tex.cpp index f616172461..0c22905fd8 100644 --- a/source/lib/res/graphics/ogl_tex.cpp +++ b/source/lib/res/graphics/ogl_tex.cpp @@ -424,11 +424,9 @@ static LibError OglTex_reload(OglTex* ot, const PIVFS& vfs, const VfsPath& pathn if(!(ot->flags & OT_TEX_VALID)) { shared_ptr file; size_t fileSize; - if(vfs->LoadFile(pathname, file, fileSize) >= 0) - { - if(tex_decode(file, fileSize, &ot->t) >= 0) - ot->flags |= OT_TEX_VALID; - } + RETURN_ERR(vfs->LoadFile(pathname, file, fileSize)); + if(tex_decode(file, fileSize, &ot->t) >= 0) + ot->flags |= OT_TEX_VALID; } glGenTextures(1, &ot->id);