ustream-ssl: openssl: fix bio memory leak
authorPan Chen <serial115200@outlook.com>
Mon, 2 Nov 2020 01:53:28 +0000 (09:53 +0800)
committerDaniel Golle <daniel@makrotopia.org>
Mon, 23 Nov 2020 02:16:43 +0000 (02:16 +0000)
free memory of bio method when ustream be freed

Signed-off-by: Pan Chen <serial115200@outlook.com>
openssl_bio_compat.h
ustream-io-openssl.c

index 9355c863c439acdafee82fb92943127cf3e379ea..39a0455f3d6ee6c41975e7a5299bd0ecb52b780b 100644 (file)
@@ -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 */
index 606ed4a36f4050cd63b98b4d56bbcaa1f68f8984..c9d7fae1efa04d6b0c1b41b63bb58a5fc9305dd2 100644 (file)
@@ -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;
 }