From a4d2edf18dcc34fada55560eee9eae76fb976d86 Mon Sep 17 00:00:00 2001
From: Roman Tsisyk <roman@tsisyk.com>
Date: Thu, 23 Jun 2016 09:29:32 +0300
Subject: [PATCH] phia: fix memory leak in findByKey()

Regression introduced by 335391d0c582ae7a376ca8a5827dc318d4d774ea
---
 src/box/phia_index.cc | 3 +++
 test/phia/info.result | 4 ++--
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/src/box/phia_index.cc b/src/box/phia_index.cc
index 442a2f9e6d..3644d45564 100644
--- a/src/box/phia_index.cc
+++ b/src/box/phia_index.cc
@@ -130,6 +130,9 @@ PhiaIndex::findByKey(struct phia_tuple *phia_key) const
 	if (result == NULL) /* not found */
 		return NULL;
 
+	auto tuple_guard = make_scoped_guard([=] {
+		phia_tuple_unref(db, result);
+	});
 	return phia_convert_tuple(db, result, key_def, format);
 }
 
diff --git a/test/phia/info.result b/test/phia/info.result
index 82ccd8a964..76da1861e5 100644
--- a/test/phia/info.result
+++ b/test/phia/info.result
@@ -116,8 +116,8 @@ box_info_sort(box.info.phia())
     - cursor_read_disk: 0 0 0.0
     - delete: '0'
     - delete_latency: 0 0 0.0
-    - documents: '3'
-    - documents_used: '102'
+    - documents: '2'
+    - documents_used: '68'
     - get: '1'
     - get_latency: <get_latency>
     - get_read_cache: 0 0 0.0
-- 
GitLab