Module: kamailio
Branch: master
Commit: 1128df71dcba1cd97898c2970e7cd3221256adb1
URL: 
https://github.com/kamailio/kamailio/commit/1128df71dcba1cd97898c2970e7cd3221256adb1

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2023-06-13T09:45:13+02:00

cdp: safety checks on error cleanup for diameter_peer_init_real()

---

Modified: src/modules/cdp/diameter_peer.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/1128df71dcba1cd97898c2970e7cd3221256adb1.diff
Patch: 
https://github.com/kamailio/kamailio/commit/1128df71dcba1cd97898c2970e7cd3221256adb1.patch

---

diff --git a/src/modules/cdp/diameter_peer.c b/src/modules/cdp/diameter_peer.c
index bea1d1f0717..294d8d640ea 100644
--- a/src/modules/cdp/diameter_peer.c
+++ b/src/modules/cdp/diameter_peer.c
@@ -151,7 +151,6 @@ int diameter_peer_init_real()
        if(!cdp_sessions_init(config->sessions_hash_size))
                goto error;
 
-
        /* add callback for messages - used to implement the API */
        cb_add(api_callback, 0);
 
@@ -162,16 +161,20 @@ int diameter_peer_init_real()
                shm_free(shutdownx);
        if(config)
                free_dp_config(config);
-       i = pid_list->head;
-       while(i) {
-               j = i->next;
-               shm_free(i);
-               i = j;
+       if(pid_list) {
+               i = pid_list->head;
+               while(i) {
+                       j = i->next;
+                       shm_free(i);
+                       i = j;
+               }
+               shm_free(pid_list);
+       }
+       if(pid_list_lock) {
+               lock_get(pid_list_lock);
+               lock_destroy(pid_list_lock);
+               lock_dealloc((void *)pid_list_lock);
        }
-       shm_free(pid_list);
-       lock_get(pid_list_lock);
-       lock_destroy(pid_list_lock);
-       lock_dealloc((void *)pid_list_lock);
        return 0;
 }
 

_______________________________________________
Kamailio (SER) - Development Mailing List
To unsubscribe send an email to sr-dev-le...@lists.kamailio.org

Reply via email to