Fix memory leak in GetWorkingDirectory.

It was just one leak per engine launch so it's not relevant. But there's no reason to do manual buffer management when StdStrBuf is used anyway.
shapetextures
Sven Eberhardt 2015-09-12 03:05:16 -04:00
parent d6751bff84
commit e229090141
1 changed files with 3 additions and 4 deletions

View File

@ -623,8 +623,7 @@ bool MakeOriginalFilename(char *szFilename)
const char *GetWorkingDirectory()
{
#ifdef _WIN32
static char *buffer = 0;
if (buffer) StdBuf::DeletePointer(buffer);
static StdStrBuf buffer;
wchar_t *widebuf = 0;
DWORD widebufsz = GetCurrentDirectoryW(0, 0);
widebuf = new wchar_t[widebufsz];
@ -632,9 +631,9 @@ const char *GetWorkingDirectory()
delete[] widebuf;
return 0;
}
StdStrBuf path(widebuf);
buffer.Take(StdStrBuf(widebuf));
delete[] widebuf;
return buffer = path.GrabPointer();
return buffer.getData();
#else
static char buf[_MAX_PATH+1];
return getcwd(buf,_MAX_PATH);