mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 21:23:58 +01:00
Fix even more dead code and resource leaks in the unit tests
Found by coverity
This commit is contained in:
parent
96b1bd4fb8
commit
52263b0dda
@ -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
|
||||
|
@ -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,
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user