[lvm-devel] [PATCH 7/7] config_def_check: Fix memory leak

Peter Rajnoha prajnoha at redhat.com
Tue Apr 16 08:47:12 UTC 2013


On 01.04.2013 23:35, Tony Asleson wrote:
> There is no need to strdup a key when inserting into
> the hash table as the table allocates memory and copies
> the string.  This was causing memory to be lost.
> 
> Signed-off-by: Tony Asleson <tasleson at redhat.com>
> ---
>  lib/config/config.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/config/config.c b/lib/config/config.c
> index 009eb5f..2c77f30 100644
> --- a/lib/config/config.c
> +++ b/lib/config/config.c
> @@ -577,7 +577,7 @@ int config_def_check(struct cmd_context *cmd, int force, int skip, int suppress_
>  				cmd->cft_def_hash = NULL;
>  				r = 0; goto out;
>  			}
> -			dm_hash_insert(cmd->cft_def_hash, dm_strdup(vp), def);
> +			dm_hash_insert(cmd->cft_def_hash, vp, def);
>  		}
>  	}
>  
> 

I've committed this one. Thanks for spotting it!

Peter




More information about the lvm-devel mailing list