Module: kamailio
Branch: master
Commit: 3614b4e66d1b57dc722139fc0e1ccd8d838f13ee
URL: 
https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8d838f13ee

Author: Daniel-Constantin Mierla <[email protected]>
Committer: Daniel-Constantin Mierla <[email protected]>
Date: 2017-12-08T16:50:51+01:00

db_postgres: avoid potential double free if sb url parsing fails

---

Modified: src/modules/db_postgres/pg_uri.c

---

Diff:  
https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8d838f13ee.diff
Patch: 
https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8d838f13ee.patch

---

diff --git a/src/modules/db_postgres/pg_uri.c b/src/modules/db_postgres/pg_uri.c
index 6170de310e..3e4f9a32bc 100644
--- a/src/modules/db_postgres/pg_uri.c
+++ b/src/modules/db_postgres/pg_uri.c
@@ -255,8 +255,10 @@ static int parse_postgres_uri(struct pg_uri *res, str *uri)
        return 0;
 
 err:
-       if(prev_token)
-               pkg_free(prev_token);
+       if(prev_token) {
+               if(res==NULL || (res->username!=prev_token && 
res->host!=prev_token))
+                       pkg_free(prev_token);
+       }
        if(res == NULL)
                return -1;
        if(res->username) {


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

Reply via email to