Skip to content
Snippets Groups Projects
Commit 5568a037 authored by alexander.lysikov's avatar alexander.lysikov
Browse files

fixed memory crash in console

parent 03b95a26
Branches feature-4530
No related tags found
3 merge requests!251Master,!250Master,!221fixed memory crash in console
Pipeline #5693 passed with stage
in 20 seconds
......@@ -69,8 +69,16 @@ static void dap_app_cli_http_read(uint64_t *socket, dap_app_cli_cmd_state_t *l_c
l_cmd->cmd_res_len = atoi(l_str_ptr + strlen(l_cont_len_str));
if (l_cmd->cmd_res_len == 0) {
s_status = DAP_CLI_ERROR_FORMAT;
} else {
}
else {
s_status++;
// resize buffer for received data
if (l_cmd->cmd_res_len > l_cmd->cmd_res_len_max) {
size_t l_len_max = l_cmd->cmd_res_len_max;
l_cmd->cmd_res_len_max = l_cmd->cmd_res_len + 1;
l_cmd->cmd_res = DAP_REALLOC(l_cmd->cmd_res, l_cmd->cmd_res_len_max);
memset(l_cmd->cmd_res + l_len_max, 0, l_cmd->cmd_res_len_max - l_len_max);
}
}
} else {
break;
......@@ -181,7 +189,8 @@ int dap_app_cli_post_command( dap_app_cli_connect_param_t *a_socket, dap_app_cli
return -1;
}
s_status = 1;
a_cmd->cmd_res = DAP_NEW_Z_SIZE(char, DAP_CLI_HTTP_RESPONSE_SIZE_MAX);
a_cmd->cmd_res_len_max = DAP_CLI_HTTP_RESPONSE_SIZE_MAX;
a_cmd->cmd_res = DAP_NEW_Z_SIZE(char, a_cmd->cmd_res_len_max);
a_cmd->cmd_res_cur = 0;
dap_string_t *l_cmd_data = dap_string_new(a_cmd->cmd_name);
if (a_cmd->cmd_param) {
......
......@@ -34,6 +34,7 @@ typedef struct dap_app_cli_cmd_state {
int ret_code;
// for reply
char *cmd_res;
size_t cmd_res_len_max;
size_t cmd_res_len;
size_t cmd_res_cur;
} dap_app_cli_cmd_state_t;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment