Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladislav Shpilevoy <v.shpilevoy@tarantool.org>
To: Kirill Shcherbatov <kshcherbatov@tarantool.org>,
	tarantool-patches@freelists.org
Subject: [tarantool-patches] Re: [PATCH v1 1/1] box: fix empty tuple invalid update
Date: Tue, 23 Apr 2019 13:11:32 +0300	[thread overview]
Message-ID: <231e1c1c-d33a-2132-3602-e37fa2010b8d@tarantool.org> (raw)
In-Reply-To: <8d2b8471b96efc182d82301808fe9ffec394ee5f.1556007413.git.kshcherbatov@tarantool.org>

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);

  reply	other threads:[~2019-04-23 10:11 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23  8:17 [tarantool-patches] " Kirill Shcherbatov
2019-04-23 10:11 ` Vladislav Shpilevoy [this message]
2019-04-23 10:17   ` [tarantool-patches] " Kirill Shcherbatov
2019-04-23 10:20     ` Vladislav Shpilevoy
2019-04-23 10:30 ` Kirill Yukhin

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=231e1c1c-d33a-2132-3602-e37fa2010b8d@tarantool.org \
    --to=v.shpilevoy@tarantool.org \
    --cc=kshcherbatov@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='[tarantool-patches] Re: [PATCH v1 1/1] box: fix empty tuple invalid update' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox