- check for empty strings before using substr to avoid crashes with more strict C++ engine

This commit is contained in:
SoftCoder
2017-09-30 21:46:56 -07:00
parent a7a92056eb
commit edfb1508f5
6 changed files with 49 additions and 53 deletions

View File

@@ -78,7 +78,7 @@ void StaticSound::load(const string &path) {
if(GlobalStaticFlags::getIsNonGraphicalModeEnabled() == true) {
return;
}
string ext= path.substr(path.find_last_of('.')+1);
string ext = (path.empty() == false ? path.substr(path.find_last_of('.')+1) : "");
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
if(soundFileLoader == NULL) {
@@ -116,7 +116,7 @@ void StrSound::open(const string &path) {
return;
}
string ext= path.substr(path.find_last_of('.')+1);
string ext = (path.empty() == false ? path.substr(path.find_last_of('.')+1) : "");
soundFileLoader= SoundFileLoaderFactory::getInstance()->newInstance(ext);
soundFileLoader->open(path, &info);