[tarantool-patches] Re: [PATCH v1 1/1] box: fix empty tuple invalid update

Vladislav Shpilevoy v.shpilevoy at tarantool.org
Tue Apr 23 13:11:32 MSK 2019


Hi! Thanks for the patch!

On 23/04/2019 11:17, Kirill Shcherbatov wrote:
> The tuple:update() used to work incorrectly in case of empty
> tuple produced with box.tuple.new{} because update_create_rope
> unconditionally initialized a new rope with [tuple_data,
> mp_next(tuple_data)] field that might not exists.
> 
> Closes #4041
> ---
> http://github.com/tarantool/tarantool/tree/kshch/gh-4041-empty-tuple-update
> https://github.com/tarantool/tarantool/issues/4041
> 
>  src/box/tuple_update.c  |  2 ++
>  test/box/tuple.result   | 21 +++++++++++++++++++++
>  test/box/tuple.test.lua | 10 ++++++++++
>  3 files changed, 33 insertions(+)
> 
> diff --git a/src/box/tuple_update.c b/src/box/tuple_update.c
> index 01c55fb1a..849073258 100644
> --- a/src/box/tuple_update.c
> +++ b/src/box/tuple_update.c
> @@ -834,6 +834,8 @@ update_create_rope(struct tuple_update *update, const char *tuple_data,
>  		return -1;
>  	const char *field = tuple_data;
>  	const char *end = tuple_data_end;
> +	if (field == end)
> +		return 0;

A few lines above you allocate struct update_field, which
is unused when field == end. Please, move this check before
update->alloc().

>  
>  	/* Add first field to rope */
>  	mp_next(&tuple_data);




More information about the Tarantool-patches mailing list