Module: kamailio
Branch: master
Commit: 47aa53ebd55eba4b36c38329f8619d9f7d20c076
URL: 
https://github.com/kamailio/kamailio/commit/47aa53ebd55eba4b36c38329f8619d9f7d20c076

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2025-04-21T08:24:18+02:00

cdp: free in case of errors inside load_certificates()

---

Modified: src/modules/cdp/cdp_tls.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/47aa53ebd55eba4b36c38329f8619d9f7d20c076.diff
Patch: 
https://github.com/kamailio/kamailio/commit/47aa53ebd55eba4b36c38329f8619d9f7d20c076.patch

---

diff --git a/src/modules/cdp/cdp_tls.c b/src/modules/cdp/cdp_tls.c
index a3cfdfa9252..f2c7c7b8b63 100644
--- a/src/modules/cdp/cdp_tls.c
+++ b/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)) {

_______________________________________________
Kamailio - Development Mailing List -- sr-dev@lists.kamailio.org
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org
Important: keep the mailing list in the recipients, do not reply only to the 
sender!

Reply via email to