From: Christian Brauner Date: Mon, 28 Sep 2015 11:33:33 +0000 (+0200) Subject: Free allocated memory on failure (v2) X-Git-Tag: lxc-2.0.0.beta1~120 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=196a808645ad403a68a9ccfa3ef4463d0291abb5;p=thirdparty%2Flxc.git Free allocated memory on failure (v2) Signed-off-by: Christian Brauner Acked-by: Serge E. Hallyn --- diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c index 21a64f701..846fd82ce 100644 --- a/src/lxc/bdev.c +++ b/src/lxc/bdev.c @@ -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; }