fix crash when decode query

This commit is contained in:
Xuan Sang LE 2018-02-08 23:58:27 +01:00
parent 101cbead6c
commit 08e3e118c4

View File

@ -487,9 +487,11 @@ dictionary decode_request(int client,const char* method, char* url)
if(strcmp(method,"GET") == 0) if(strcmp(method,"GET") == 0)
{ {
if(query)
{
request = decode_url_request(query); request = decode_url_request(query);
if(query) free(query); free(query);
}
if(ws && ws_key != NULL) if(ws && ws_key != NULL)
{ {
ws_confirm_request(client, ws_key); ws_confirm_request(client, ws_key);
@ -753,10 +755,10 @@ dictionary decode_multi_part_request(int client,const char* ctype)
*/ */
dictionary decode_url_request(const char* query) dictionary decode_url_request(const char* query)
{ {
if(query == NULL) return NULL;
char* str_copy = strdup(query); char* str_copy = strdup(query);
//str_copy = ; //str_copy = ;
char* token; char* token;
if(query == NULL) return NULL;
if(strlen(query) == 0) return NULL; if(strlen(query) == 0) return NULL;
dictionary dic = dict(); dictionary dic = dict();
while ((token = strsep(&str_copy, "&"))) while ((token = strsep(&str_copy, "&")))