[PATCH 3/7] test: self: digest: don't leak digest buffers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The selftest leaks memory by letting the pointers go out of scope.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 test/self/digest.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/test/self/digest.c b/test/self/digest.c
index 4cda5b09637b..32815c85ba70 100644
--- a/test/self/digest.c
+++ b/test/self/digest.c
@@ -47,7 +47,7 @@ static void __test_digest(bool option,
 			  const char *algo, struct digest_test_case *t,
 			  const char *func, int line)
 {
-	unsigned char *output, *digest;
+	unsigned char *output = NULL, *digest = NULL;
 	struct digest *d;
 	int hash_len, digest_len;
 	u64 start;
@@ -103,8 +103,14 @@ static void __test_digest(bool option,
 		goto fail;
 	}
 
+	digest_free(d);
+	free(digest);
+	free(output);
 	return;
 fail:
+	digest_free(d);
+	free(digest);
+	free(output);
 	failed_tests++;
 }
 
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux