Module: kamailio
Branch: master
Commit: 3614b4e66d1b57dc722139fc0e1ccd8d838f13ee
URL:
https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
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/3614b4e66d1b57dc722139fc0e1ccd8…
Patch:
https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8…
---
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) {