diff --git a/cli/filelister_unix.cpp b/cli/filelister_unix.cpp index f9263eb78..e961f9a84 100644 --- a/cli/filelister_unix.cpp +++ b/cli/filelister_unix.cpp @@ -60,8 +60,13 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, if (filename[filename.length()-1] != '/') { // File +#ifdef PATH_MAX char fname[PATH_MAX]; if (realpath(filename.c_str(), fname) == NULL) +#else + char *fname; + if ((fname = realpath(filename.c_str(), NULL)) == NULL) +#endif { continue; } @@ -69,6 +74,9 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, // Does absolute path exist? then bail out if (std::find(absolute.begin(), absolute.end(), std::string(fname)) != absolute.end()) { +#ifndef PATH_MAX + free(fname); +#endif continue; } @@ -77,6 +85,10 @@ void FileListerUnix::recursiveAddFiles2(std::vector &relative, relative.push_back(filename); absolute.push_back(fname); } + +#ifndef PATH_MAX + free(fname); +#endif } else {