From d5b25ca1a827d3ec07be9607232edb0c27172918 Mon Sep 17 00:00:00 2001 From: jimying Date: Thu, 24 Oct 2024 23:05:56 +0800 Subject: [PATCH] Fix memory error (#508) --- src/webui.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/webui.c b/src/webui.c index 65824d0f4..97b9b952e 100644 --- a/src/webui.c +++ b/src/webui.c @@ -4138,7 +4138,7 @@ static char* _webui_get_file_name_from_url(const char* url) { } // Copy the path to a new string - char* file = strdup(pos); + char* file = _webui_str_dup(pos); // Find the position of the first '?' char* question_mark = strchr(file, '?'); @@ -4181,9 +4181,6 @@ static char* _webui_get_full_path(_webui_window_t* win, const char* file) { } #endif - // Clean - _webui_free_mem((void*)file); - #ifdef WEBUI_LOG_VERBOSE printf("[Core]\t\t_webui_get_full_path() -> Full path: [%s]\n", full_path); #endif @@ -8857,7 +8854,8 @@ static void _webui_receive(_webui_window_t* win, struct mg_connection* client, if (win->ws_block) { // Process the packet in this current thread _webui_ws_process(win, client, connection_id, arg_ptr, arg_len, ++recvNum, event_type); - _webui_free_mem((void*)arg_ptr); + if (arg_ptr != data) + _webui_free_mem((void*)arg_ptr); } else { // Process the packet in a new thread @@ -9331,7 +9329,7 @@ static void _webui_ws_process( // Check the response if (_webui_is_empty(event_inf->response)) - event_inf->response = (char*)""; + event_inf->response = NULL; #ifdef WEBUI_LOG printf(