Module: kamailio
Branch: master
Commit: 4f6a2686c01a65fe3a23e4d2057c7940eedcf12a
URL: 
https://github.com/kamailio/kamailio/commit/4f6a2686c01a65fe3a23e4d2057c7940eedcf12a

Author: Daniel-Constantin Mierla <mico...@gmail.com>
Committer: Daniel-Constantin Mierla <mico...@gmail.com>
Date: 2023-12-05T12:20:01+01:00

topoh: reorder conditions for safety of cleaning on error

- in the part related to the new th_build_socket_strings() internal function

---

Modified: src/modules/topoh/topoh_mod.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/4f6a2686c01a65fe3a23e4d2057c7940eedcf12a.diff
Patch: 
https://github.com/kamailio/kamailio/commit/4f6a2686c01a65fe3a23e4d2057c7940eedcf12a.patch

---

diff --git a/src/modules/topoh/topoh_mod.c b/src/modules/topoh/topoh_mod.c
index dbb08d83084..d40f70fdd86 100644
--- a/src/modules/topoh/topoh_mod.c
+++ b/src/modules/topoh/topoh_mod.c
@@ -357,14 +357,18 @@ int th_build_socket_strings(socket_info_t *socket)
        return 0;
 
 error:
-       if(socket_strings->ip.s != NULL)
-               pkg_free(socket_strings->ip.s);
-       if(table_entry->key.s != NULL)
-               pkg_free(table_entry->key.s);
-       if(table_entry != NULL)
-               pkg_free(table_entry);
-       if(socket_strings != NULL)
+       if(socket_strings != NULL) {
+               if(socket_strings->ip.s != NULL) {
+                       pkg_free(socket_strings->ip.s);
+               }
                pkg_free(socket_strings);
+       }
+       if(table_entry != NULL) {
+               if(table_entry->key.s != NULL) {
+                       pkg_free(table_entry->key.s);
+               }
+               pkg_free(table_entry);
+       }
        return -1;
 }
 

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

Reply via email to