[patches] [PATCH 2/4] Fix a pair of memory leaks

Vladimir Davydov vdavydov.dev at gmail.com
Mon Mar 12 16:06:48 MSK 2018


On Mon, Mar 12, 2018 at 12:53:34AM +0300, Vladislav Shpilevoy wrote:
> Signed-off-by: Vladislav Shpilevoy <v.shpilevoy at tarantool.org>
> ---
>  src/box/alter.cc   | 2 +-
>  src/box/vy_index.c | 3 +--
>  2 files changed, 2 insertions(+), 3 deletions(-)

Looks OK to me.

> 
> diff --git a/src/box/alter.cc b/src/box/alter.cc
> index 8a62d8ed8..7eec4786b 100644
> --- a/src/box/alter.cc
> +++ b/src/box/alter.cc
> @@ -326,7 +326,7 @@ index_def_new_from_tuple(struct tuple *tuple, struct space *space)
>  		tnt_raise(OutOfMemory, sizeof(*part_def) * part_count,
>  			  "malloc", "key_part_def");
>  	}
> -	auto key_def_guard = make_scoped_guard([=] {
> +	auto key_def_guard = make_scoped_guard([&] {
>  		free(part_def);
>  		free(key_def);
>  	});
> diff --git a/src/box/vy_index.c b/src/box/vy_index.c
> index 5809204dc..68fccab52 100644
> --- a/src/box/vy_index.c
> +++ b/src/box/vy_index.c
> @@ -308,8 +308,7 @@ vy_index_delete(struct vy_index *index)
>  	tuple_format_unref(index->disk_format);
>  	tuple_format_unref(index->mem_format_with_colmask);
>  	tuple_format_unref(index->upsert_format);
> -	if (index->id > 0)
> -		free(index->cmp_def);
> +	free(index->cmp_def);
>  	free(index->key_def);
>  	histogram_delete(index->run_hist);
>  	vy_index_stat_destroy(&index->stat);



More information about the Tarantool-patches mailing list