diff --git a/ext/dtls/gstdtlscertificate.c b/ext/dtls/gstdtlscertificate.c index c1c96020f2..c2d9bb217f 100644 --- a/ext/dtls/gstdtlscertificate.c +++ b/ext/dtls/gstdtlscertificate.c @@ -207,12 +207,13 @@ init_generated (GstDtlsCertificate * self) rsa = RSA_new (); if (rsa != NULL) { BIGNUM *e = BN_new (); - if (e != NULL && BN_set_word (e, RSA_F4) - && RSA_generate_key_ex (rsa, 2048, e, NULL)) { + if (e == NULL || !BN_set_word (e, RSA_F4) + || !RSA_generate_key_ex (rsa, 2048, e, NULL)) { RSA_free (rsa); rsa = NULL; } - BN_free (e); + if (e) + BN_free (e); } #endif