]> 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>
Fri, 15 Dec 2017 12:35:28 +0000 (13:35 +0100)
do not pass NULL pointer to chdir()

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

index c83a4455ed6ae98aef2ba70cc267dab869587291..76349f88797d29f6b0b3922c4e79238fe3c1539b 100644 (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. */