[lxc-devel] [PATCH] fix memory leaks reported by cppcheck in src/lxc/bdev.c

Serge Hallyn serge.hallyn at ubuntu.com
Mon Nov 18 15:28:07 UTC 2013


Quoting S.Çağlar Onur (caglar at 10ur.org):
> Signed-off-by: S.Çağlar Onur <caglar at 10ur.org>

Acked-by: Serge E. Hallyn <serge.hallyn at ubuntu.com>

> ---
>  src/lxc/bdev.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/src/lxc/bdev.c b/src/lxc/bdev.c
> index c7e5e5e..6acd29a 100644
> --- a/src/lxc/bdev.c
> +++ b/src/lxc/bdev.c
> @@ -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';
> -- 
> 1.8.3.2
> 
> 
> ------------------------------------------------------------------------------
> DreamFactory - Open Source REST & JSON Services for HTML5 & Native Apps
> OAuth, Users, Roles, SQL, NoSQL, BLOB Storage and External API Access
> Free app hosting. Or install the open source package on any LAMP server.
> Sign up and see examples for AngularJS, jQuery, Sencha Touch and Native!
> http://pubads.g.doubleclick.net/gampad/clk?id=63469471&iu=/4140/ostg.clktrk
> _______________________________________________
> Lxc-devel mailing list
> Lxc-devel at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/lxc-devel




More information about the lxc-devel mailing list