From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from smtp40.i.mail.ru (smtp40.i.mail.ru [94.100.177.100]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dev.tarantool.org (Postfix) with ESMTPS id 258B4469719 for ; Wed, 11 Nov 2020 12:38:31 +0300 (MSK) From: Kirill Yukhin Date: Wed, 11 Nov 2020 12:38:10 +0300 Message-Id: <4e5bec04c11d294335c6725a8def2034c8bf3385.1605087058.git.kyukhin@tarantool.org> Subject: [Tarantool-patches] [PATCH] Fix tuple leak in vy_build_recover_stmt List-Id: Tarantool development patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: korablev@tarantool.org, alyapunov@tarantool.org Cc: tarantool-patches@dev.tarantool.org Variable `old` which contains tuple reference wasn't unrefed at all. Fix this. --- Branch: https://github.com/tarantool/tarantool/tree/kyukhin/fix-vy-build-recover-leak Issue: N/A CI: https://gitlab.com/tarantool/tarantool/-/pipelines/212266538 src/box/vinyl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/box/vinyl.c b/src/box/vinyl.c index 57e2839..0ff1262 100644 --- a/src/box/vinyl.c +++ b/src/box/vinyl.c @@ -4020,8 +4020,10 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk, if (old_tuple != NULL) { delete = vy_stmt_new_surrogate_delete(lsm->mem_format, old_tuple); - if (delete == NULL) + if (delete == NULL) { + tuple_unref(old_tuple); return -1; + } } enum iproto_type type = vy_stmt_type(mem_stmt); if (type == IPROTO_REPLACE || type == IPROTO_INSERT) { @@ -4045,6 +4047,9 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk, goto err; } + if (old_tuple != NULL) + tuple_unref(old_tuple); + /* Insert DELETE + INSERT into the LSM tree. */ if (delete != NULL) { int rc = vy_build_insert_stmt(lsm, lsm->mem, delete, lsn); @@ -4061,6 +4066,8 @@ vy_build_recover_stmt(struct vy_lsm *lsm, struct vy_lsm *pk, return 0; err: + if (old_tuple != NULL) + tuple_unref(old_tuple); if (delete != NULL) tuple_unref(delete); return -1; -- 2.11.0