gnunet

Main GNUnet Logic
Log | Files | Refs | Submodules | README | LICENSE

commit 72b16124ed7fd7977c984d6a2dde9b6e9f8bdc81
parent fa443d7741e2ce7d0e0627ba61ed6d16e8f4df0f
Author: ulfvonbelow <strilen@tilde.club>
Date:   Sun, 29 Jan 2023 07:06:29 -0600

GNSRECORD: fix memory leaks in tests.

This allows us to use sanitizers to find bugs that matter.

Signed-off-by: Martin Schanzenbach <schanzen@gnunet.org>

Diffstat:
Msrc/gnsrecord/test_gnsrecord_block_expiration.c | 3+++
Msrc/gnsrecord/test_gnsrecord_crypto.c | 2++
2 files changed, 5 insertions(+), 0 deletions(-)

diff --git a/src/gnsrecord/test_gnsrecord_block_expiration.c b/src/gnsrecord/test_gnsrecord_block_expiration.c @@ -78,6 +78,7 @@ run (void *cls, char *const *args, const char *cfgfile, rd[1].expiration_time = expiration_abs_shadow.abs_value_us; rd[1].record_type = TEST_RECORD_TYPE; rd[1].data_size = TEST_RECORD_DATALEN; + GNUNET_free (rd[1].data); rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN); rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW; memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); @@ -86,6 +87,8 @@ run (void *cls, char *const *args, const char *cfgfile, GNUNET_GNSRECORD_record_get_expiration_time (2, rd, GNUNET_TIME_UNIT_ZERO_ABS).abs_value_us); + GNUNET_free (rd[0].data); + GNUNET_free (rd[1].data); res = 0; } diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c @@ -143,6 +143,8 @@ test_with_type (struct GNUNET_IDENTITY_PrivateKey *privkey) s_name, &rd_decrypt_cb, NULL)); + for (int i = 0; i < RECORDS; i++) GNUNET_free(s_rd[i].data); + GNUNET_free (s_rd); GNUNET_free (block); }