From b63c769a56497325acda986184993d2d8fc7084c Mon Sep 17 00:00:00 2001 From: emlai Date: Wed, 14 Sep 2016 15:00:00 +0300 Subject: [PATCH] Fix crash when passing "HScore.dat" to outputfile ctor --- FeLib/Source/save.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/FeLib/Source/save.cpp b/FeLib/Source/save.cpp index 6cafc537a..7c3a73d3a 100644 --- a/FeLib/Source/save.cpp +++ b/FeLib/Source/save.cpp @@ -26,10 +26,14 @@ outputfile::outputfile(cfestring& FileName, truth AbortOnErr) : FileName(FileName) { - // Make sure the directory exists first. - festring DirectoryPath = FileName; - DirectoryPath.Resize(FileName.FindLast('/')); - MakePath(DirectoryPath); + // If FileName contains a directory, make sure the directory exists first. + festring::csizetype LastPathSeparatorPos = FileName.FindLast('/'); + if(LastPathSeparatorPos != festring::NPos) + { + festring DirectoryPath = FileName; + DirectoryPath.Resize(LastPathSeparatorPos); + MakePath(DirectoryPath); + } Buffer = fopen(FileName.CStr(), "wb");