From 08e3e118c41b043b2f86354e20072cfe97bc5cca Mon Sep 17 00:00:00 2001 From: Xuan Sang LE Date: Thu, 8 Feb 2018 23:58:27 +0100 Subject: [PATCH] fix crash when decode query --- http_server.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/http_server.c b/http_server.c index b88bf84..2ff8d48 100644 --- a/http_server.c +++ b/http_server.c @@ -487,9 +487,11 @@ dictionary decode_request(int client,const char* method, char* url) if(strcmp(method,"GET") == 0) { - - request = decode_url_request(query); - if(query) free(query); + if(query) + { + request = decode_url_request(query); + free(query); + } if(ws && ws_key != NULL) { 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) { + if(query == NULL) return NULL; char* str_copy = strdup(query); //str_copy = ; char* token; - if(query == NULL) return NULL; if(strlen(query) == 0) return NULL; dictionary dic = dict(); while ((token = strsep(&str_copy, "&")))