]> granicus.if.org Git - icinga2/commitdiff
Added support for POSIX.1-2001 realpath() (Hello Solaris 10).
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 25 May 2012 18:30:11 +0000 (20:30 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 25 May 2012 18:30:11 +0000 (20:30 +0200)
base/application.cpp

index 0e5531c2451fe4a486f602cbde56e8cb19bc413f..63c21556cb8f2f83fd3bda7d15eb0ddd2ad519d0 100644 (file)
@@ -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];