fix invalid read problem

This commit is contained in:
Xuan Sang LE 2018-03-17 15:49:37 +01:00
parent 88a85fb36a
commit 64b27c0dd3
2 changed files with 6 additions and 2 deletions

View File

@ -881,13 +881,15 @@ dictionary decode_url_request(const char* query)
while ((token = strsep(&str_copy, "&")))
{
char* key;
char* val;
char* val = NULL;
if(strlen(token)>0)
{
key = strsep(&token,"=");
if(key && strlen(key)>0)
{
val = strsep(&token,"=");
if(!val)
val = "";
dput(dic,key,url_decode(val));
}
}

View File

@ -249,6 +249,8 @@ int regex_match(const char* expr,const char* search, int msize, regmatch_t* matc
return ret;
}
char *url_decode(const char *str) {
if(!str)
return NULL;
char *pstr = str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
while (*pstr) {