Skip to content
Snippets Groups Projects
Commit 71a1c0a8 authored by Aomx's avatar Aomx
Browse files

prevented potential core dump by duplicating script_path for printing.

parent 5db4e03a
No related branches found
No related tags found
No related merge requests found
......@@ -573,7 +573,7 @@ void run_code_event(struct state *state, struct event *event,
{
DEBUGP("%d: run code event\n", event->line_number);
char *error = NULL;
char *error = NULL, *script_path = NULL;
/* Wait for the right time before firing off this event. */
wait_for_event(state);
......@@ -618,8 +618,10 @@ void run_code_event(struct state *state, struct event *event,
return;
error_out:
script_path = strdup(state->config->script_path);
state_free(state);
die("%s:%d: runtime error in code: %s\n",
state->config->script_path, event->line_number, error);
script_path, event->line_number, error);
free(script_path);
free(error);
}
......@@ -591,9 +591,11 @@ void run_script(struct config *config, struct script *script)
wire_client_next_event(state->wire_client, NULL);
if (code_execute(state->code, &error)) {
char *script_path = strdup(state->config->script_path);
state_free(state);
die("%s: error executing code: %s\n",
state->config->script_path, error);
script_path, error);
free(script_path);
free(error);
}
......
......@@ -36,6 +36,7 @@
void run_command_event(
struct state *state, struct event *event, struct command_spec *command)
{
char *script_path = NULL;
DEBUGP("%d: command: `%s`\n", event->line_number,
command->command_line);
......@@ -48,9 +49,11 @@ void run_command_event(
return;
error_out:
script_path = strdup(state->config->script_path);
state_free(state);
die("%s:%d: error executing `%s` command: %s\n",
state->config->script_path, event->line_number,
script_path, event->line_number,
command->command_line, error);
free(script_path);
free(error);
}
......@@ -1924,7 +1924,7 @@ static void invoke_system_call(
{
DEBUGP("%d: invoke call: %s\n", event->line_number, syscall->name);
char *error = NULL;
char *error = NULL, *script_path = NULL;
const char *name = syscall->name;
struct expression_list *args = NULL;
int i = 0;
......@@ -1958,10 +1958,12 @@ static void invoke_system_call(
return;
error_out:
script_path = strdup(state->config->script_path);
state_free(state);
die("%s:%d: runtime error in %s call: %s\n",
state->config->script_path, event->line_number,
script_path, event->line_number,
syscall->name, error);
free(script_path);
free(error);
}
......@@ -2008,7 +2010,7 @@ static int yield(void)
static void enqueue_system_call(
struct state *state, struct event *event, struct syscall_spec *syscall)
{
char *error = NULL;
char *error = NULL, *script_path = NULL;
bool done = false;
/* Wait if there are back-to-back blocking system calls. */
......@@ -2059,10 +2061,12 @@ static void enqueue_system_call(
return;
error_out:
script_path = strdup(state->config->script_path);
state_free(state);
die("%s:%d: runtime error in %s call: %s\n",
state->config->script_path, event->line_number,
script_path, event->line_number,
syscall->name, error);
free(script_path);
free(error);
}
......
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