aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorulfvonbelow <strilen@tilde.club>2023-01-29 07:06:29 -0600
committerMartin Schanzenbach <schanzen@gnunet.org>2023-02-06 13:55:02 +0900
commit72b16124ed7fd7977c984d6a2dde9b6e9f8bdc81 (patch)
tree4e51b06f5285d4f2591b07fc200a95ae4ce053f0
parentfa443d7741e2ce7d0e0627ba61ed6d16e8f4df0f (diff)
downloadgnunet-72b16124ed7fd7977c984d6a2dde9b6e9f8bdc81.tar.gz
gnunet-72b16124ed7fd7977c984d6a2dde9b6e9f8bdc81.zip
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>
-rw-r--r--src/gnsrecord/test_gnsrecord_block_expiration.c3
-rw-r--r--src/gnsrecord/test_gnsrecord_crypto.c2
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
index 69f7f6aa1..3ef02e631 100644
--- 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,
78 rd[1].expiration_time = expiration_abs_shadow.abs_value_us; 78 rd[1].expiration_time = expiration_abs_shadow.abs_value_us;
79 rd[1].record_type = TEST_RECORD_TYPE; 79 rd[1].record_type = TEST_RECORD_TYPE;
80 rd[1].data_size = TEST_RECORD_DATALEN; 80 rd[1].data_size = TEST_RECORD_DATALEN;
81 GNUNET_free (rd[1].data);
81 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN); 82 rd[1].data = GNUNET_malloc (TEST_RECORD_DATALEN);
82 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW; 83 rd[1].flags = GNUNET_GNSRECORD_RF_SHADOW;
83 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN); 84 memset ((char *) rd[1].data, TEST_RECORD_DATA, TEST_RECORD_DATALEN);
@@ -86,6 +87,8 @@ run (void *cls, char *const *args, const char *cfgfile,
86 GNUNET_GNSRECORD_record_get_expiration_time (2, 87 GNUNET_GNSRECORD_record_get_expiration_time (2,
87 rd, 88 rd,
88 GNUNET_TIME_UNIT_ZERO_ABS).abs_value_us); 89 GNUNET_TIME_UNIT_ZERO_ABS).abs_value_us);
90 GNUNET_free (rd[0].data);
91 GNUNET_free (rd[1].data);
89 res = 0; 92 res = 0;
90} 93}
91 94
diff --git a/src/gnsrecord/test_gnsrecord_crypto.c b/src/gnsrecord/test_gnsrecord_crypto.c
index 5b1032f1e..92a7a9f1f 100644
--- 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)
143 s_name, 143 s_name,
144 &rd_decrypt_cb, 144 &rd_decrypt_cb,
145 NULL)); 145 NULL));
146 for (int i = 0; i < RECORDS; i++) GNUNET_free(s_rd[i].data);
147 GNUNET_free (s_rd);
146 GNUNET_free (block); 148 GNUNET_free (block);
147} 149}
148 150