]> 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>
Mon, 28 Sep 2015 19:48:36 +0000 (15:48 -0400)
Signed-off-by: Christian Brauner <christianvanbrauner@gmail.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/bdev.c

index 21a64f7014cab7ef63cb00c5346ff4fded97e7cc..846fd82ce556abf035cb890903dd488798bde29b 100644 (file)
@@ -2461,12 +2461,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;
                }