aboutsummaryrefslogtreecommitdiff
path: root/src/or/test.c
diff options
context:
space:
mode:
authorNick Mathewson <nickm@torproject.org>2009-01-13 14:43:51 +0000
committerNick Mathewson <nickm@torproject.org>2009-01-13 14:43:51 +0000
commita33452c40149842fda3ce2a201a722009e7e1456 (patch)
tree5bc3efc1704b0fb1dafface01fbda1e6a8da6e3b /src/or/test.c
parentc32a4ce6b3ac5d24ff53639d2c00d9864e9bf22c (diff)
downloadtor-a33452c40149842fda3ce2a201a722009e7e1456.tar.gz
tor-a33452c40149842fda3ce2a201a722009e7e1456.zip
Fix up (I hope) most ot the things that coverity suddenly claimed were REVERSE_INULL. This is what we get for bragging about being down to 0 issues.
svn:r18096
Diffstat (limited to 'src/or/test.c')
-rw-r--r--src/or/test.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/or/test.c b/src/or/test.c
index 6f28f86f1e..f555d75673 100644
--- a/src/or/test.c
+++ b/src/or/test.c
@@ -2401,13 +2401,12 @@ _compare_strings_for_pqueue(const void *s1, const void *s2)
static void
test_util_pqueue(void)
{
- smartlist_t *sl = NULL;
+ smartlist_t *sl = smartlist_create();
int (*cmp)(const void *, const void*);
#define OK() smartlist_pqueue_assert_ok(sl, cmp)
cmp = _compare_strings_for_pqueue;
- sl = smartlist_create();
smartlist_pqueue_add(sl, cmp, (char*)"cows");
smartlist_pqueue_add(sl, cmp, (char*)"zebras");
smartlist_pqueue_add(sl, cmp, (char*)"fish");
@@ -2451,8 +2450,8 @@ test_util_pqueue(void)
#undef OK
done:
- if (sl)
- smartlist_free(sl);
+
+ smartlist_free(sl);
}
/** Run unit tests for compression functions */
@@ -3921,17 +3920,16 @@ test_rend_fns(void)
char address2[] = "aaaaaaaaaaaaaaaa.onion";
char address3[] = "fooaddress.exit";
char address4[] = "www.torproject.org";
- rend_service_descriptor_t *d1 = NULL, *d2 = NULL;
+ rend_service_descriptor_t *d1 =
+ tor_malloc_zero(sizeof(rend_service_descriptor_t));
+ rend_service_descriptor_t *d2 = NULL;
char *encoded = NULL;
size_t len;
- crypto_pk_env_t *pk1 = NULL, *pk2 = NULL;
time_t now;
int i;
- pk1 = pk_generate(0);
- pk2 = pk_generate(1);
+ crypto_pk_env_t *pk1 = pk_generate(0), *pk2 = pk_generate(1);
/* Test unversioned (v0) descriptor */
- d1 = tor_malloc_zero(sizeof(rend_service_descriptor_t));
d1->pk = crypto_pk_dup_key(pk1);
now = time(NULL);
d1->timestamp = now;
@@ -3967,6 +3965,13 @@ test_rend_fns(void)
test_assert(EXIT_HOSTNAME == parse_extended_hostname(address3));
test_assert(NORMAL_HOSTNAME == parse_extended_hostname(address4));
+ crypto_free_pk_env(pk1);
+ crypto_free_pk_env(pk2);
+ pk1 = pk2 = NULL;
+ rend_service_descriptor_free(d1);
+ rend_service_descriptor_free(d2);
+ d1 = d2 = NULL;
+
done:
if (pk1)
crypto_free_pk_env(pk1);
@@ -4530,6 +4535,10 @@ test_rend_fns_v2(void)
test_eq(gen_info->port, par_info->port);
}
+ rend_service_descriptor_free(parsed);
+ rend_service_descriptor_free(generated);
+ parsed = generated = NULL;
+
done:
if (descs) {
for (i = 0; i < smartlist_len(descs); i++)