From 03a307b58ddc6244d3fad8d77d7f0bac0a24e05d Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Mon, 17 Aug 2015 22:40:33 +0800 Subject: Fix crashes in smAnmFile. Do not crash if a non-exist file is requested in a DTP file. Fix several stupid typos. Fix missing smEntity3D constructor. Fix line spacing in smTTFont. --- extensions/smdatapack.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'extensions/smdatapack.cpp') diff --git a/extensions/smdatapack.cpp b/extensions/smdatapack.cpp index 78082bb..2e77324 100644 --- a/extensions/smdatapack.cpp +++ b/extensions/smdatapack.cpp @@ -36,7 +36,7 @@ bool smDtpFileR::openDtp(const char* path) m[std::string(f.path)]=f; } } -bool smDtpFileR::openDtpFromMemory(char* ptr,DWORD size) +bool smDtpFileR::openDtpFromMemory(const char* ptr,DWORD size) { enmemory=true;msize=size; if(!ptr||size<4)return false; @@ -84,6 +84,7 @@ char* smDtpFileR::getPrevFile(const char* path) char* smDtpFileR::getFilePtr(const char* path) { std::string fns(path); + if(m.find(fns)==m.end()){printf("error: file not found in the archive.\n");return NULL;} if(m.at(fns).data)return m.at(fns).data; else { @@ -112,6 +113,7 @@ char* smDtpFileR::getFilePtr(const char* path) void smDtpFileR::releaseFilePtr(const char* path) { std::string fns(path); + if(m.find(fns)==m.end()){printf("error: file not found in the archive.\n");return;} if(m[fns].data) { delete[] m[fns].data; @@ -119,7 +121,7 @@ void smDtpFileR::releaseFilePtr(const char* path) } } DWORD smDtpFileR::getFileSize(const char* path) -{return m[std::string(path)].size;} +{if(m.find(std::string(path))==m.end()){printf("error: file not found in the archive.\n");return 0;}return m[std::string(path)].size;} smDtpFileW::smDtpFileW(){fcnt=0;} bool smDtpFileW::addFile(const char* path,const char* realpath) -- cgit v1.2.3