Module: kamailio
Branch: 5.1
Commit: e5d96dec3f986a2d98ea5e3c09da1fac3f45c14a
URL:
https://github.com/kamailio/kamailio/commit/e5d96dec3f986a2d98ea5e3c09da1fa…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: 2017-12-08T16:54:29+01:00
db_postgres: avoid potential double free if sb url parsing fails
(cherry picked from commit 3614b4e66d1b57dc722139fc0e1ccd8d838f13ee)
---
Modified: src/modules/db_postgres/pg_uri.c
---
Diff:
https://github.com/kamailio/kamailio/commit/e5d96dec3f986a2d98ea5e3c09da1fa…
Patch:
https://github.com/kamailio/kamailio/commit/e5d96dec3f986a2d98ea5e3c09da1fa…
---
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) {