Skip to content

Commit

Permalink
Fix memory error (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
jimying authored Oct 24, 2024
1 parent 15e2d68 commit d5b25ca
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions src/webui.c
Original file line number Diff line number Diff line change
Expand Up @@ -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, '?');
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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(
Expand Down

0 comments on commit d5b25ca

Please sign in to comment.