do not pass NULL pointer to chdir()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
This commit is contained in:
Christian Brauner 2017-12-09 19:22:32 +01:00
parent 3ca108148b
commit d6d979bc2b
No known key found for this signature in database
GPG Key ID: 8EB056D53EECB12D

View File

@ -1186,9 +1186,11 @@ int lxc_attach(const char *name, const char *lxcpath,
new_cwd = options->initial_cwd;
else
new_cwd = cwd;
ret = chdir(new_cwd);
if (ret < 0)
WARN("Could not change directory to \"%s\".", new_cwd);
if (new_cwd) {
ret = chdir(new_cwd);
if (ret < 0)
WARN("Could not change directory to \"%s\"", new_cwd);
}
free(cwd);
/* Now create the real child process. */