diff --git a/src/util/util.c b/src/util/util.c index 34cfc212e8c90affa40be4671a61255d4260795f..445fd4e7d46660f07d909cdf17e9c8203799f21e 100644 --- a/src/util/util.c +++ b/src/util/util.c @@ -1213,6 +1213,7 @@ int virFileResolveLink(const char *linkpath, */ char *virFindFileInPath(const char *file) { + char *path; char pathenv[PATH_MAX]; char *penv = pathenv; char *pathseg; @@ -1232,7 +1233,9 @@ char *virFindFileInPath(const char *file) } /* copy PATH env so we can tweak it */ - if (virStrcpyStatic(pathenv, getenv("PATH")) == NULL) + path = getenv("PATH"); + + if (path == NULL || virStrcpyStatic(pathenv, path) == NULL) return NULL; /* for each path segment, append the file to search for and test for