Fix even more dead code and resource leaks in the unit tests

Found by coverity
This commit is contained in:
Nick Mathewson 2013-02-11 15:20:20 -05:00
parent 96b1bd4fb8
commit 52263b0dda
3 changed files with 8 additions and 9 deletions

View File

@ -124,8 +124,10 @@ bench_onion_TAP(void)
key = crypto_pk_new();
key2 = crypto_pk_new();
crypto_pk_generate_key_with_bits(key, 1024);
crypto_pk_generate_key_with_bits(key2, 1024);
if (crypto_pk_generate_key_with_bits(key, 1024) < 0)
goto done;
if (crypto_pk_generate_key_with_bits(key2, 1024) < 0)
goto done;
reset_perftime();
start = perftime();
@ -171,7 +173,9 @@ bench_onion_TAP(void)
printf("Client-side, part 2: %f usec.\n",
NANOCOUNT(start, end, iters)/1e3);
done:
crypto_pk_free(key);
crypto_pk_free(key2);
}
#ifdef CURVE25519_ENABLED

View File

@ -24,7 +24,6 @@ test_replaycache_alloc(void)
r = replaycache_new(600, 300);
test_assert(r != NULL);
if (!r) goto done;
done:
if (r) replaycache_free(r);
@ -40,7 +39,6 @@ test_replaycache_miss(void)
r = replaycache_new(600, 300);
test_assert(r != NULL);
if (!r) goto done;
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -61,7 +59,6 @@ test_replaycache_hit(void)
r = replaycache_new(600, 300);
test_assert(r != NULL);
if (!r) goto done;
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -87,7 +84,6 @@ test_replaycache_age(void)
r = replaycache_new(600, 300);
test_assert(r != NULL);
if (!r) goto done;
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -119,7 +115,6 @@ test_replaycache_elapsed(void)
r = replaycache_new(600, 300);
test_assert(r != NULL);
if (!r) goto done;
result =
replaycache_add_and_test_internal(1200, r, test_buffer,
@ -146,7 +141,6 @@ test_replaycache_noexpire(void)
r = replaycache_new(0, 0);
test_assert(r != NULL);
if (!r) goto done;
result =
replaycache_add_and_test_internal(1200, r, test_buffer,

View File

@ -53,7 +53,6 @@ test_util_read_until_eof_impl(const char *fname, size_t file_len,
fd = open(fifo_name, O_RDONLY|O_BINARY);
tt_int_op(fd, >=, 0);
str = read_file_to_str_until_eof(fd, read_limit, &sz);
close(fd);
tt_assert(str != NULL);
if (read_limit < file_len)
@ -69,6 +68,8 @@ test_util_read_until_eof_impl(const char *fname, size_t file_len,
tor_free(fifo_name);
tor_free(test_str);
tor_free(str);
if (fd >= 0)
close(fd);
}
static void