Tarantool development patches archive
 help / color / mirror / Atom feed
From: Vladimir Davydov <vdavydov.dev@gmail.com>
To: kostja@tarantool.org
Cc: tarantool-patches@freelists.org
Subject: [PATCH] vinyl: fix memory leak in slice stream
Date: Thu, 25 Oct 2018 20:37:23 +0300	[thread overview]
Message-ID: <f69c1c469b3ba220641cc303d12af9ea3b58c1dc.1540488695.git.vdavydov.dev@gmail.com> (raw)

If a tuple read from a run by a slice stream happens to be out of the
slice bounds, it will never be freed. Fix it.

The leak was introduced by commit c174c985485c ("vinyl: implement new
simple write iterator").
---
https://github.com/tarantool/tarantool/commits/dv/vy-fix-memleak-in-slice-stream

 src/box/vy_run.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/box/vy_run.c b/src/box/vy_run.c
index bb5baf2c..454833e7 100644
--- a/src/box/vy_run.c
+++ b/src/box/vy_run.c
@@ -2567,8 +2567,10 @@ vy_slice_stream_next(struct vy_stmt_stream *virt_stream, struct tuple **ret)
 	if (stream->slice->end != NULL &&
 	    stream->page_no >= stream->slice->last_page_no &&
 	    vy_tuple_compare_with_key(tuple, stream->slice->end,
-				      stream->cmp_def) >= 0)
+				      stream->cmp_def) >= 0) {
+		tuple_unref(tuple);
 		return 0;
+	}
 
 	/* We definitely has the next non-null tuple. Save it in stream */
 	if (stream->tuple != NULL)
-- 
2.11.0

             reply	other threads:[~2018-10-25 17:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-10-25 17:37 Vladimir Davydov [this message]
2018-10-26  8:06 ` 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=f69c1c469b3ba220641cc303d12af9ea3b58c1dc.1540488695.git.vdavydov.dev@gmail.com \
    --to=vdavydov.dev@gmail.com \
    --cc=kostja@tarantool.org \
    --cc=tarantool-patches@freelists.org \
    --subject='Re: [PATCH] vinyl: fix memory leak in slice stream' \
    /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