]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
Free allocated memory on failure (v2)
authorChristian Brauner <christianvanbrauner@gmail.com>
Mon, 28 Sep 2015 11:33:33 +0000 (13:33 +0200)
committerStéphane Graber <stgraber@ubuntu.com>
Tue, 29 Sep 2015 16:40:53 +0000 (12:40 -0400)
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/bdev.c

index 33740919b1280ea0a87139f6d0cde75a5f019dbe..3c338c6048939d650ea57e918b087041f973eb87 100644 (file)
@@ -2469,12 +2469,15 @@ static int overlayfs_clonepaths(struct bdev *orig, struct bdev *new, const char
                // and needs to be on the same filesystem as upperdir,
                // so it's OK for it to be empty.
                work = malloc(lastslashidx + 7);
-               if (!work)
+               if (!work) {
+                       free(delta);
                        return -1;
+               }
                strncpy(work, new->dest, lastslashidx+1);
                strcpy(work+lastslashidx, "olwork");
                if (mkdir(work, 0755) < 0) {
                        SYSERROR("error: mkdir %s", work);
+                       free(delta);
                        free(work);
                        return -1;
                }