View Issue Details
| ID | Project | Category | View Status | Date Submitted | Last Update |
|---|---|---|---|---|---|
| 0007648 | GNUnet | GNS | public | 2023-01-30 00:48 | 2023-06-01 20:26 |
| Reporter | ulfvonbelow | Assigned To | schanzen | ||
| Priority | normal | Severity | trivial | Reproducibility | always |
| Status | closed | Resolution | fixed | ||
| Product Version | Git master | ||||
| Target Version | 0.19.4 | Fixed in Version | 0.19.4 | ||
| Summary | 0007648: Memory leaks in gnsrecord tests | ||||
| Description | See attached patch | ||||
| Steps To Reproduce | ./configure --enable-sanitizer make make install make check | ||||
| Additional Information | Patch attached. | ||||
| Tags | memory-leak, patch | ||||
| Attached Files | 0001-GNSRECORD-fix-memory-leaks-in-tests.patch (2,028 bytes)
From a8f55505130ee693ef9aa0f7ebff010f828606a4 Mon Sep 17 00:00:00 2001
From: ulfvonbelow <strilen@tilde.club>
Date: Sun, 29 Jan 2023 07:06:29 -0600
Subject: [PATCH] GNSRECORD: fix memory leaks in tests.
This allows us to use sanitizers to find bugs that matter.
---
src/gnsrecord/test_gnsrecord_block_expiration.c | 3 +++
src/gnsrecord/test_gnsrecord_crypto.c | 2 ++
2 files changed, 5 insertions(+)
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,
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
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)
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);
}
--
2.38.1
| ||||
| Date Modified | Username | Field | Change |
|---|---|---|---|
| 2023-01-30 00:48 | ulfvonbelow | New Issue | |
| 2023-01-30 00:48 | ulfvonbelow | Tag Attached: memory-leak | |
| 2023-01-30 00:48 | ulfvonbelow | Tag Attached: patch | |
| 2023-01-30 00:48 | ulfvonbelow | File Added: 0001-GNSRECORD-fix-memory-leaks-in-tests.patch | |
| 2023-02-06 05:55 | schanzen | Assigned To | => schanzen |
| 2023-02-06 05:55 | schanzen | Status | new => resolved |
| 2023-02-06 05:55 | schanzen | Resolution | open => fixed |
| 2023-02-06 05:55 | schanzen | Fixed in Version | => 0.19.4 |
| 2023-02-06 06:19 | schanzen | Target Version | => 0.19.4 |
| 2023-06-01 20:26 | schanzen | Note Added: 0020221 | |
| 2023-06-01 20:26 | schanzen | Status | resolved => closed |