Commit 2d2c32c8 authored by Arnaud Blanchard's avatar Arnaud Blanchard
Browse files

Avoid to destroy the memory for the argument as it is already done when the line is destroyed

parent 49d18160
......@@ -134,8 +134,6 @@ void blc_command_add(const char *command_name, type_blc_command_cb callback, con
APPEND_ITEM(&blc_commands, &blc_commands_nb, &tmp_command);
}
/* line may be allocated indefinitly, but it does not happen often. */
static void blc_command_interpret_block(){
blc_mem line, parameter;
size_t line_capability=0;
......@@ -166,7 +164,7 @@ static void blc_command_interpret_block(){
if (parameter.size == 0) //No text after the command
{
parameter.data = NULL;
parameter.chars = NULL;
if (command->prompt != NULL) //A text was expected
{
fprintf(stderr, "%s:", command->prompt);
......@@ -174,7 +172,7 @@ static void blc_command_interpret_block(){
parameter.chars[parameter.size]=0;
}
if (command->callback) command->callback( parameter.chars, command->user_data); //In which callback is NULL ??
FREE(parameter.chars);
parameter.~blc_mem();
line_capability=0;
break;
}
......@@ -187,6 +185,7 @@ static void blc_command_interpret_block(){
}
}
if (command < blc_commands) fprintf(stderr, "Unknown command in: %s\n", line.chars);
parameter.chars=NULL; //Avoid to be destructed twice
}
void blc_command_interpret(){
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment