Memory leaks in evpdm
pietercardoen opened this issue · 4 comments
Hello
I've detected another memory leak, this time in evpdm. The patch is added below:
From bd7744b Mon Sep 17 00:00:00 2001
From: Pieter Cardoen pieter.cardoen@hotmail.com
Date: Tue, 30 Jan 2018 20:57:52 +0100
Subject: [PATCH] Fixed memory leak in evpmd
src/include/private/ssl_compat.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/include/private/ssl_compat.h b/src/include/private/ssl_compat.h
index 1ada408..8664a20 100644
--- a/src/include/private/ssl_compat.h
+++ b/src/include/private/ssl_compat.h
@@ -9,7 +9,7 @@ class EvpMdCtx {
public:
EvpMdCtx() { EVP_MD_CTX_init(&ctx_); }
- ~EvpMdCtx() {}
-
~EvpMdCtx() { EVP_MD_CTX_cleanup(&ctx_); }
EVP_MD_CTX* get() { return &ctx_; }
--
2.7.4
Thanks! Do you happen to have a pull request with the change by any chance?
I never did that but I took time to read how to do it. Pull request is done ;).
As a user of jwt-cpp, I was just passing by and checked out the PR. I can confirm it solves the leak on productive code. Also I'd suggest having following (or similar) change in the test code so the test output also stays clean at valgrind.
diff --git a/test/validators/validators_factory_test.cpp b/test/validators/validators_factory_test.cpp
index 87e6ac9..1cfa951 100644
--- a/test/validators/validators_factory_test.cpp
+++ b/test/validators/validators_factory_test.cpp
@@ -217,7 +217,7 @@ TEST(parse_test, accepts_multiple_types) {
""key1" : { "HS256" : { "secret" : "key1" } }, "
""key3" : { "HS512" : { "secret" : "key3" } } "
"} }";
- ASSERT_NO_THROW(MessageValidatorFactory::Build(json));
- ASSERT_NO_THROW(std::unique_ptr(MessageValidatorFactory::Build(json)));
}
TEST(parse_test, rsa_not_in_pem_format) {