From: Gunnar Beutner Date: Fri, 25 May 2012 18:30:11 +0000 (+0200) Subject: Added support for POSIX.1-2001 realpath() (Hello Solaris 10). X-Git-Tag: v0.0.1~490 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0527ff012a11e2b8e14460915035d1249a508c7c;p=icinga2 Added support for POSIX.1-2001 realpath() (Hello Solaris 10). --- diff --git a/base/application.cpp b/base/application.cpp index 0e5531c24..63c21556c 100644 --- a/base/application.cpp +++ b/base/application.cpp @@ -326,7 +326,7 @@ string Application::GetExeDirectory(void) const #ifndef _WIN32 char Cwd[MAXPATHLEN]; - char *Buf, *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN]; + char *PathEnv, *Directory, PathTest[MAXPATHLEN], FullExePath[MAXPATHLEN]; bool FoundPath; const char *argv0 = m_Arguments[0].c_str(); @@ -367,7 +367,8 @@ string Application::GetExeDirectory(void) const } } - if ((Buf = realpath(FullExePath, NULL)) == NULL) + char Buf[PATH_MAX]; + if (realpath(FullExePath, Buf) == NULL) throw PosixException("realpath failed", errno); // remove filename @@ -377,8 +378,6 @@ string Application::GetExeDirectory(void) const *LastSlash = '\0'; ExePath = string(Buf); - - free(Buf); #else /* _WIN32 */ char FullExePath[MAXPATHLEN];