[sr-dev] git:master:3614b4e6: db_postgres: avoid potential double free if sb url parsing fails
Daniel-Constantin Mierla
miconda at gmail.com
Fri Dec 8 16:51:18 CET 2017
Module: kamailio
Branch: master
Commit: 3614b4e66d1b57dc722139fc0e1ccd8d838f13ee
URL: https://github.com/kamailio/kamailio/commit/3614b4e66d1b57dc722139fc0e1ccd8d838f13ee
Author: Daniel-Constantin Mierla <miconda at gmail.com>
Committer: Daniel-Constantin Mierla <miconda at 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/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) {
More information about the sr-dev
mailing list