Module: kamailio
Branch: master
Commit: 2a67f79945475cfbe8d033b4df39018a73346db1
URL: 
https://github.com/kamailio/kamailio/commit/2a67f79945475cfbe8d033b4df39018a73346db1

Author: Lucian Balaceanu <[email protected]>
Committer: Lucian Balaceanu <[email protected]>
Date: 2017-08-03T10:28:28+03:00

p_usrloc: fix resource leak

---

Modified: src/modules/p_usrloc/ul_db_layer.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/2a67f79945475cfbe8d033b4df39018a73346db1.diff
Patch: 
https://github.com/kamailio/kamailio/commit/2a67f79945475cfbe8d033b4df39018a73346db1.patch

---

diff --git a/src/modules/p_usrloc/ul_db_layer.c 
b/src/modules/p_usrloc/ul_db_layer.c
index 36f02d5437..036adf23bb 100644
--- a/src/modules/p_usrloc/ul_db_layer.c
+++ b/src/modules/p_usrloc/ul_db_layer.c
@@ -218,27 +218,26 @@ int ul_add_domain_db(str * d, int t, str * url) {
                return -1;
        }
        memset(new_d, 0, sizeof(ul_domain_db_list_t));
-       if(!d){
-               return -1;
-       }
-       if(!d->s){
-               return -1;              
-       }
+
+       if(!d || !d->s) goto error;
+
        if((new_d->domain.name.s = pkg_malloc(d->len + 1)) == NULL) {
-               return -1;
+               goto error;
        }
+
        if(t == DB_TYPE_SINGLE) {
                if(url) {
                        LM_DBG("url: %.*s", url->len, url->s);
                        if((new_d->domain.url.s = pkg_malloc(url->len + 1)) == 
NULL) {
-                               return -1;
+                               goto error;
                        }
+
                        strncpy(new_d->domain.url.s, url->s, url->len);
                        new_d->domain.url.s[url->len] = '\0';
                        new_d->domain.url.len = url->len;
                } else {
                        if((new_d->domain.url.s = pkg_malloc(default_db_url.len 
+ 1)) == NULL) {
-                               return -1;
+                               goto error;
                        }
                        strcpy(new_d->domain.url.s, default_db_url.s);
                        new_d->domain.url.len = default_db_url.len;
@@ -250,6 +249,9 @@ int ul_add_domain_db(str * d, int t, str * url) {
        new_d->next = domain_db_list;
        domain_db_list = new_d;
        return 1;
+error:
+       pkg_free(new_d);
+       return -1;
 }
 
 ul_domain_db_t * ul_find_domain(const char * s) {


_______________________________________________
Kamailio (SER) - Development Mailing List
[email protected]
https://lists.kamailio.org/cgi-bin/mailman/listinfo/sr-dev

Reply via email to