فهرست منبع

cdp: free in case of errors inside load_certificates()

(cherry picked from commit 47aa53ebd55eba4b36c38329f8619d9f7d20c076)
Daniel-Constantin Mierla 4 ماه پیش
والد
کامیت
544866d63d
1فایلهای تغییر یافته به همراه4 افزوده شده و 0 حذف شده
  1. 4 0
      src/modules/cdp/cdp_tls.c

+ 4 - 0
src/modules/cdp/cdp_tls.c

@@ -149,16 +149,20 @@ int load_certificates(SSL_CTX *ctx, str *cert, str *key)
 	}
 	if(pkg_str_dup(&key_fixed, key) < 0) {
 		LM_ERR("Failed to copy key parameter\n");
+		pkg_free(cert_fixed.s);
 		return -1;
 	}
 	if(!SSL_CTX_use_certificate_chain_file(ctx, cert_fixed.s)) {
 		LM_ERR("Unable to load certificate file\n");
 		TLS_LM_ERR("load_cert:", ctx);
+		pkg_free(key_fixed.s);
+		pkg_free(cert_fixed.s);
 		return -1;
 	}
 	if(SSL_CTX_use_PrivateKey_file(ctx, key_fixed.s, SSL_FILETYPE_PEM) <= 0) {
 		LM_ERR("Unable to load private key file\n");
 		TLS_LM_ERR("load_private_key:", ctx);
+		pkg_free(key_fixed.s);
 		return -1;
 	}
 	if(!SSL_CTX_check_private_key(ctx)) {