Address memory leaks in Freezer test Not sure what's the best way to fix thawing of BoolNums.
Project: http://git-wip-us.apache.org/repos/asf/lucy/repo Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/d460538f Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/d460538f Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/d460538f Branch: refs/heads/master Commit: d460538f26959f7bce097f5e9a11aa4616e2671f Parents: 4e18b58 Author: Nick Wellnhofer <[email protected]> Authored: Tue May 5 11:34:17 2015 +0200 Committer: Nick Wellnhofer <[email protected]> Committed: Tue May 5 11:34:17 2015 +0200 ---------------------------------------------------------------------- core/Lucy/Test/Util/TestFreezer.c | 1 + core/Lucy/Util/Freezer.c | 2 ++ 2 files changed, 3 insertions(+) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/lucy/blob/d460538f/core/Lucy/Test/Util/TestFreezer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Test/Util/TestFreezer.c b/core/Lucy/Test/Util/TestFreezer.c index 7657a00..01fb687 100644 --- a/core/Lucy/Test/Util/TestFreezer.c +++ b/core/Lucy/Test/Util/TestFreezer.c @@ -95,6 +95,7 @@ test_hash(TestBatchRunner *runner) { String *str = TestUtils_random_string(rand() % 1200); Integer32 *num = Int32_new(i); Hash_Store(wanted, str, (Obj*)num); + DECREF(str); } { http://git-wip-us.apache.org/repos/asf/lucy/blob/d460538f/core/Lucy/Util/Freezer.c ---------------------------------------------------------------------- diff --git a/core/Lucy/Util/Freezer.c b/core/Lucy/Util/Freezer.c index 621d63c..9cc9410 100644 --- a/core/Lucy/Util/Freezer.c +++ b/core/Lucy/Util/Freezer.c @@ -142,6 +142,8 @@ Freezer_deserialize(Obj *obj, InStream *instream) { if (Obj_Is_A(obj, BOOLNUM)) { bool value = !!InStream_Read_U8(instream); Obj *result = value ? INCREF(CFISH_TRUE) : INCREF(CFISH_FALSE); + // FIXME: This DECREF is essentially a no-op causing a + // memory leak. DECREF(obj); obj = result; }
