Bug 670788 - When looking for the executable path on Unix, only use realpath() when we got a file path in the first place. r=bsmedberg

This commit is contained in:
Mike Hommey 2011-07-21 09:55:51 +02:00
Родитель 0ec7b9b37e
Коммит ab86342353
1 изменённых файлов: 4 добавлений и 2 удалений

Просмотреть файл

@ -46,6 +46,7 @@
#include <CoreFoundation/CoreFoundation.h>
#elif defined(XP_UNIX)
#include <sys/stat.h>
#include <string.h>
#endif
namespace mozilla {
@ -102,10 +103,11 @@ private:
// multiple applications, we will try a series of techniques:
//
// 1) use realpath() on argv[0], which works unless we're loaded from the
// PATH
// PATH. Only do so if argv[0] looks like a path (contains a /).
// 2) manually walk through the PATH and look for ourself
// 3) give up
if (realpath(argv0, aResult) && stat(aResult, &fileStat) == 0)
if (strchr(argv0, '/') && realpath(argv0, aResult) &&
stat(aResult, &fileStat) == 0)
return NS_OK;
const char *path = getenv("PATH");