From 9956f167d1db0f91ed35f9fb28b711586a416d42 Mon Sep 17 00:00:00 2001 From: Ben Pfaff Date: Sat, 14 Oct 2006 23:23:17 +0000 Subject: [PATCH] Fix memory leak in test_casereader_clone(). --- src/language/tests/ChangeLog | 5 +++++ src/language/tests/casefile-test.c | 15 ++++++++++++--- 2 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/language/tests/ChangeLog b/src/language/tests/ChangeLog index 80c27c0d..605b8cc5 100644 --- a/src/language/tests/ChangeLog +++ b/src/language/tests/ChangeLog @@ -1,3 +1,8 @@ +Sat Oct 14 16:21:45 2006 Ben Pfaff + + * casefile-test.c: (test_casereader_clone) Free cases that we + read, to avoid memory leak. + Tue Jun 6 18:48:00 2006 Ben Pfaff * casefile-test.c: (test_casefile) Test the new casereader_seek() diff --git a/src/language/tests/casefile-test.c b/src/language/tests/casefile-test.c index a1927ddb..30ffdd2b 100644 --- a/src/language/tests/casefile-test.c +++ b/src/language/tests/casefile-test.c @@ -232,14 +232,17 @@ test_casereader_clone (struct casereader *reader1, size_t case_cnt) /* Read a 3rd of the cases */ for ( i = 0 ; i < case_cnt / 3 ; ++i ) - casereader_read (reader1, &c1); + { + casereader_read (reader1, &c1); + case_destroy (&c1); + } clone = casereader_clone (reader1); /* Copy all the cases into a new file */ while( casereader_read (reader1, &c1)) { - casefile_append (newfile, &c1); + casefile_append_xfer (newfile, &c1); cases ++; } @@ -254,13 +257,19 @@ test_casereader_clone (struct casereader *reader1, size_t case_cnt) cases --; if ( ! casereader_read_xfer (newreader, &c2) ) - break; + { + case_destroy (&c1); + break; + } v1 = case_data_all (&c1) ; v2 = case_data_all (&c2) ; if ( 0 != memcmp (v1, v2, value_cnt * MAX_SHORT_STRING)) fail_test ("Cloned reader read different value at case %ld", cases); + + case_destroy (&c1); + case_destroy (&c2); } if ( cases > 0 ) -- 2.30.2