From d2686431758f9269b6a0ccdc8ffd024e9ea63f4c Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20Ma=C5=9Blanka?= <piotr.maslanka@henrietta.com.pl>
Date: Wed, 30 Jun 2021 18:45:48 +0200
Subject: [PATCH] fix a mem leak

---
 README.md          | 2 ++
 setup.cfg          | 2 +-
 tempsdb/series.pyx | 7 +++----
 3 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/README.md b/README.md
index 6648276..9760fd5 100644
--- a/README.md
+++ b/README.md
@@ -52,6 +52,8 @@ Then copy your resulting wheel and install it via pip on the target system.
 ## v0.6.2
 
 * added the context manager syntax to VarlenIterator
+* fixed a memory leak that happened during getting current value
+    from an empty series
 
 ## v0.6.1
 
diff --git a/setup.cfg b/setup.cfg
index 1da8734..3e4aa7c 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -1,7 +1,7 @@
 # coding: utf-8
 [metadata]
 name = tempsdb
-version = 0.6.2a2
+version = 0.6.2a3
 long-description = file: README.md
 long-description-content-type = text/markdown; charset=UTF-8
 license_files = LICENSE
diff --git a/tempsdb/series.pyx b/tempsdb/series.pyx
index eb51718..b0ba398 100644
--- a/tempsdb/series.pyx
+++ b/tempsdb/series.pyx
@@ -47,13 +47,12 @@ cdef class TimeSeries:
         cdef:
             Iterator it = self.iterate_range(self.last_chunk.max_ts, self.last_chunk.max_ts)
             tuple tpl = it.next_item()
+        it.close()
 
         if tpl is None:
             raise ValueError('Series is empty!')
-        try:
-            return tpl
-        finally:
-            it.close()
+
+        return tpl
 
     cpdef int disable_mmap(self) except -1:
         """
-- 
GitLab