Module: sip-router
Branch: 4.0
Commit: 8ab2488d6e693fdd7dd5fe522f32f65b6045911e
URL:
http://git.sip-router.org/cgi-bin/gitweb.cgi/sip-router/?a=commit;h=8ab2488…
Author: Daniel-Constantin Mierla <miconda(a)gmail.com>
Committer: Daniel-Constantin Mierla <miconda(a)gmail.com>
Date: Mon Apr 21 17:36:01 2014 +0200
db_mysql: reset prev_token to avoid double free in case of url parse error
- when db api v2 is used (ser modules)
(cherry picked from commit f65bf2c37bfaae740dd3cd8d686308cfa44b42f2)
(cherry picked from commit 340768948df423e25812d083fcdf09396ef763e3)
---
modules/db_mysql/my_uri.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/modules/db_mysql/my_uri.c b/modules/db_mysql/my_uri.c
index b4c5a51..1f98135 100644
--- a/modules/db_mysql/my_uri.c
+++ b/modules/db_mysql/my_uri.c
@@ -175,12 +175,14 @@ static int parse_mysql_uri(struct my_uri* res, str* uri)
case '@':
st = ST_HOST;
res->username = prev_token;
+ prev_token = 0;
if (dupl_string(&res->password, begin, uri->s + i) < 0) goto err;
begin = uri->s + i + 1;
break;
case '/':
res->host = prev_token;
+ prev_token = 0;
res->port = str2s(begin, uri->s + i - begin, 0);
if (dupl_string(&res->database, uri->s + i + 1, uri->s + uri->len)
< 0) goto err;
return 0;