Skip to content

Commit

Permalink
Fix crash when passing "HScore.dat" to outputfile ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
emlai committed Sep 15, 2016
1 parent 88175e8 commit b63c769
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions FeLib/Source/save.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");

Expand Down

0 comments on commit b63c769

Please sign in to comment.