diff options
author | Nick Mathewson <nickm@torproject.org> | 2008-12-05 02:25:39 +0000 |
---|---|---|
committer | Nick Mathewson <nickm@torproject.org> | 2008-12-05 02:25:39 +0000 |
commit | af03faa1a64d35704893926adfca13e22840a2c7 (patch) | |
tree | 25ec054b6f3771ee67e9bb469505db0a9ff2a896 /src | |
parent | 7f793fa733a89eb0dae9fd8d70ad56448ba31eb2 (diff) | |
download | tor-af03faa1a64d35704893926adfca13e22840a2c7.tar.gz tor-af03faa1a64d35704893926adfca13e22840a2c7.zip |
Fix more leaks in test_util_memarea().
svn:r17491
Diffstat (limited to 'src')
-rw-r--r-- | src/or/test.c | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/or/test.c b/src/or/test.c index dad0f41eda..c0fa05e2c8 100644 --- a/src/or/test.c +++ b/src/or/test.c @@ -3939,7 +3939,9 @@ test_util_memarea(void) { memarea_t *area = memarea_new(); char *p1, *p2, *p3, *p1_orig; + void *malloced_ptr = NULL; int i; + test_assert(area); p1_orig = p1 = memarea_alloc(area,64); @@ -3964,19 +3966,19 @@ test_util_memarea(void) p2 = memarea_alloc(area, 1); test_eq(p1+sizeof(void*), p2); { - void *ptr = tor_malloc(64); - test_assert(!memarea_owns_ptr(area, ptr)); - tor_free(ptr); + malloced_ptr = tor_malloc(64); + test_assert(!memarea_owns_ptr(area, malloced_ptr)); + tor_free(malloced_ptr); } /* memarea_memdup */ { - char *ptr = tor_malloc(64); - crypto_rand(ptr, 64); - p1 = memarea_memdup(area, ptr, 64); - test_assert(p1 != ptr); - test_memeq(p1, ptr, 64); - tor_free(ptr); + malloced_ptr = tor_malloc(64); + crypto_rand((char*)malloced_ptr, 64); + p1 = memarea_memdup(area, malloced_ptr, 64); + test_assert(p1 != malloced_ptr); + test_memeq(p1, malloced_ptr, 64); + tor_free(malloced_ptr); } /* memarea_strdup. */ @@ -4024,6 +4026,7 @@ test_util_memarea(void) done: memarea_drop_all(area); + tor_free(malloced_ptr); } static void |