mirror of
https://github.com/lxsang/ant-http
synced 2024-12-27 09:18:22 +01:00
fix invalid read problem
This commit is contained in:
parent
88a85fb36a
commit
64b27c0dd3
@ -881,13 +881,15 @@ dictionary decode_url_request(const char* query)
|
|||||||
while ((token = strsep(&str_copy, "&")))
|
while ((token = strsep(&str_copy, "&")))
|
||||||
{
|
{
|
||||||
char* key;
|
char* key;
|
||||||
char* val;
|
char* val = NULL;
|
||||||
if(strlen(token)>0)
|
if(strlen(token)>0)
|
||||||
{
|
{
|
||||||
key = strsep(&token,"=");
|
key = strsep(&token,"=");
|
||||||
if(key && strlen(key)>0)
|
if(key && strlen(key)>0)
|
||||||
{
|
{
|
||||||
val = strsep(&token,"=");
|
val = strsep(&token,"=");
|
||||||
|
if(!val)
|
||||||
|
val = "";
|
||||||
dput(dic,key,url_decode(val));
|
dput(dic,key,url_decode(val));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -249,6 +249,8 @@ int regex_match(const char* expr,const char* search, int msize, regmatch_t* matc
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
char *url_decode(const char *str) {
|
char *url_decode(const char *str) {
|
||||||
|
if(!str)
|
||||||
|
return NULL;
|
||||||
char *pstr = str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
|
char *pstr = str, *buf = malloc(strlen(str) + 1), *pbuf = buf;
|
||||||
|
|
||||||
while (*pstr) {
|
while (*pstr) {
|
||||||
|
Loading…
Reference in New Issue
Block a user