From: Christian Brauner Date: Sat, 9 Dec 2017 18:22:32 +0000 (+0100) Subject: coverity: #1425867 X-Git-Tag: lxc-2.0.10~479 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d96c566e4742b01b51553a0d029dd45d7340a694;p=thirdparty%2Flxc.git coverity: #1425867 do not pass NULL pointer to chdir() Signed-off-by: Christian Brauner --- diff --git a/src/lxc/attach.c b/src/lxc/attach.c index 7da8a7336..b2ee12977 100644 --- a/src/lxc/attach.c +++ b/src/lxc/attach.c @@ -1139,9 +1139,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. */