]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
fix memory leaks reported by cppcheck in src/lxc/bdev.c
authorS.Çağlar Onur <caglar@10ur.org>
Fri, 15 Nov 2013 04:03:58 +0000 (23:03 -0500)
committerSerge Hallyn <serge.hallyn@ubuntu.com>
Mon, 18 Nov 2013 15:28:43 +0000 (09:28 -0600)
Signed-off-by: S.Çağlar Onur <caglar@10ur.org>
Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
src/lxc/bdev.c

index c7e5e5ee3b11f8d0c1e3b40b3a0bdae8283793f8..6acd29a680e13f28a6b9c4cb4ab040262f5f2d8c 100644 (file)
@@ -962,8 +962,10 @@ static int lvm_snapshot(const char *orig, const char *path, unsigned long size)
        // check if the original lv is backed by a thin pool, in which case we
        // cannot specify a size that's different from the original size.
        ret = lvm_is_thin_volume(orig);
-       if (ret == -1)
+       if (ret == -1) {
+               free(pathdup);
                return -1;
+       }
 
        if (!ret) {
                ret = execlp("lvcreate", "lvcreate", "-s", "-L", sz, "-n", lv, orig, (char *)NULL);
@@ -1282,6 +1284,7 @@ static int btrfs_subvolume_create(const char *path)
        p = strrchr(newfull, '/');
        if (!p) {
                ERROR("bad path: %s", path);
+               free(newfull);
                return -1;
        }
        *p = '\0';
@@ -1418,6 +1421,7 @@ static int btrfs_destroy(struct bdev *orig)
        p = strrchr(newfull, '/');
        if (!p) {
                ERROR("bad path: %s", path);
+               free(newfull);
                return -1;
        }
        *p = '\0';