diff mbox series

ustream-ssl: openssl: fix bio memory leak

Message ID PS1PR03MB500329AE6D7A3778B9B54166DB100@PS1PR03MB5003.apcprd03.prod.outlook.com
State Accepted
Delegated to: Daniel Golle
Headers show
Series ustream-ssl: openssl: fix bio memory leak | expand

Commit Message

serial115200@outlook.com Nov. 2, 2020, 1:53 a.m. UTC
From: Pan Chen <serial115200@outlook.com>

free memory of bio method when ustream be freed

Signed-off-by: Pan Chen <serial115200@outlook.com>
---
 openssl_bio_compat.h | 7 +++++++
 ustream-io-openssl.c | 1 +
 2 files changed, 8 insertions(+)
diff mbox series

Patch

diff --git a/openssl_bio_compat.h b/openssl_bio_compat.h
index 9355c86..39a0455 100644
--- a/openssl_bio_compat.h
+++ b/openssl_bio_compat.h
@@ -28,6 +28,13 @@  static inline BIO_METHOD *BIO_meth_new(int type, const char *name)
 	return bm;
 }
 
+static inline void BIO_meth_free(BIO_METHOD *bm)
+{
+	if (bm != NULL) {
+		free(bm);
+	}
+}
+
 #endif /* OPENSSL_VERSION_NUMBER */
 
 #endif /* OPENSSL_BIO_COMPAT_H */
diff --git a/ustream-io-openssl.c b/ustream-io-openssl.c
index 606ed4a..c9d7fae 100644
--- a/ustream-io-openssl.c
+++ b/ustream-io-openssl.c
@@ -42,6 +42,7 @@  s_ustream_free(BIO *b)
 	BIO_set_data(b, NULL);
 	BIO_set_init(b, 0);
 	BIO_clear_flags(b, ~0);
+	BIO_meth_free(b->method);
 	return 1;
 }