You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucy.apache.org by nw...@apache.org on 2016/10/19 12:17:22 UTC

lucy git commit: Fix memory leak in HitQueue

Repository: lucy
Updated Branches:
  refs/heads/0.5 69dfc886f -> 2671da30a


Fix memory leak in HitQueue

HitQueue would leak a FieldType if the last SortRule was of type
FIELD. This wasn't discovered by our test suite because we always
break ties by DOC_ID.

Thanks to Serkan Mulayim for the report.

Fixes LUCY-315.


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/2671da30
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/2671da30
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/2671da30

Branch: refs/heads/0.5
Commit: 2671da30afade456249fe4a8c73ed4115278b984
Parents: 69dfc88
Author: Nick Wellnhofer <we...@aevum.de>
Authored: Wed Oct 19 13:29:58 2016 +0200
Committer: Nick Wellnhofer <we...@aevum.de>
Committed: Wed Oct 19 14:16:30 2016 +0200

----------------------------------------------------------------------
 core/Lucy/Search/HitQueue.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/2671da30/core/Lucy/Search/HitQueue.c
----------------------------------------------------------------------
diff --git a/core/Lucy/Search/HitQueue.c b/core/Lucy/Search/HitQueue.c
index 12324e7..4190708 100644
--- a/core/Lucy/Search/HitQueue.c
+++ b/core/Lucy/Search/HitQueue.c
@@ -108,13 +108,15 @@ HitQ_init(HitQueue *self, Schema *schema, SortSpec *sort_spec,
 void
 HitQ_Destroy_IMP(HitQueue *self) {
     HitQueueIVARS *const ivars = HitQ_IVARS(self);
-    FieldType **types = ivars->field_types;
-    FieldType **const limit = types + ivars->num_actions - 1;
-    for (; types < limit; types++) {
-        if (types) { DECREF(*types); }
+    if (ivars->field_types) {
+        FieldType **types = ivars->field_types;
+        FieldType **const limit = types + ivars->num_actions;
+        for (; types < limit; types++) {
+            DECREF(*types);
+        }
+        FREEMEM(ivars->field_types);
     }
     FREEMEM(ivars->actions);
-    FREEMEM(ivars->field_types);
     SUPER_DESTROY(self, HITQUEUE);
 }