From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: From: Vladimir Davydov Subject: [PATCH] vinyl: fix tuple leak in vy_tuple_new Date: Fri, 21 Dec 2018 18:40:23 +0300 Message-Id: <727a5cdf4c10be759cc803eb6cb1cdb51e454c2b.1545406594.git.vdavydov.dev@gmail.com> To: tarantool-patches@freelists.org List-ID: 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