diff --git a/base/application.cpp b/base/application.cpp index 1a5c9ddc3..38be79113 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -274,8 +274,8 @@ string Application::GetExeDirectory(void) return ExePath; #ifndef _WIN32 - char Buf[MAXPATHLEN], Cwd[MAXPATHLEN]; - char *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN]; + char Cwd[MAXPATHLEN]; + char *Buf, *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN]; bool FoundPath; const char *argv0 = m_Arguments[0].c_str(); @@ -319,7 +319,7 @@ string Application::GetExeDirectory(void) } } - if (realpath(FullExePath, Buf) == NULL) + if ((Buf = realpath(FullExePath, NULL)) == NULL) throw exception(/*"realpath() failed"*/); // remove filename @@ -329,6 +329,8 @@ string Application::GetExeDirectory(void) *LastSlash = '\0'; ExePath = string(Buf); + + free(Buf); #else /* _WIN32 */ char FullExePath[MAXPATHLEN]; diff --git a/base/unix.h b/base/unix.h index 9876ab5cf..ea946f348 100644 --- a/base/unix.h +++ b/base/unix.h @@ -1,6 +1,7 @@ #ifndef UNIX_H #define UNIX_H +#include #include #include #include @@ -19,10 +20,6 @@ void closesocket(SOCKET fd); #define ioctlsocket ioctl -#ifndef PATH_MAX -# define PATH_MAX 1024 -#endif /* PATH_MAX */ - #define MAXPATHLEN PATH_MAX /* default visibility takes care of exported symbols */