From: Vladimir Davydov <vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org Subject: [PATCH] vinyl: fix tuple leak in vy_tuple_new Date: Fri, 21 Dec 2018 18:40:23 +0300 [thread overview] Message-ID: <727a5cdf4c10be759cc803eb6cb1cdb51e454c2b.1545406594.git.vdavydov.dev@gmail.com> (raw) tuple_format_vtab::tuple_new() callback is supposed to return a tuple with 0 references, but vinyl implementation returns a tuple with the reference counter set to 1, effectively leaking the new tuple. How to reproduce: get a tuple from a vinyl space and update it with box.tuple.update(). The bug was introduced by commit a377332a7314 ("tuple: fix lost format on update and upsert operations"). --- src/box/vy_stmt.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/box/vy_stmt.c b/src/box/vy_stmt.c index 3e60fece..cd1ad505 100644 --- a/src/box/vy_stmt.c +++ b/src/box/vy_stmt.c @@ -86,7 +86,12 @@ vy_tuple_new(struct tuple_format *format, const char *data, const char *end) if (tuple_validate_raw(format, data) != 0) return NULL; - return vy_stmt_new_insert(format, data, end); + struct tuple *tuple = vy_stmt_new_insert(format, data, end); + if (tuple != NULL) { + tuple_bless(tuple); + tuple_unref(tuple); + } + return tuple; } struct tuple_format_vtab vy_tuple_format_vtab = { -- 2.11.0
next reply other threads:[~2018-12-21 15:40 UTC|newest] Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top 2018-12-21 15:40 Vladimir Davydov [this message] 2018-12-21 15:48 ` Vladimir Davydov
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=727a5cdf4c10be759cc803eb6cb1cdb51e454c2b.1545406594.git.vdavydov.dev@gmail.com \ --to=vdavydov.dev@gmail.com \ --cc=tarantool-patches@freelists.org \ --subject='Re: [PATCH] vinyl: fix tuple leak in vy_tuple_new' \ /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