]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
coverity: #1425867
authorChristian Brauner <christian.brauner@ubuntu.com>
Sat, 9 Dec 2017 18:22:32 +0000 (19:22 +0100)
committerChristian Brauner <christian.brauner@ubuntu.com>
Sun, 17 Dec 2017 15:33:28 +0000 (16:33 +0100)
do not pass NULL pointer to chdir()

Signed-off-by: Christian Brauner <christian.brauner@ubuntu.com>
src/lxc/attach.c

index 7da8a733654cd2d2f372eadeaa74e6ba2ebcebe6..b2ee12977c990410589dfad12674f676f6b8d9e6 100644 (file)
@@ -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. */