diff --git a/gtests/net/packetdrill/code.c b/gtests/net/packetdrill/code.c index 3f4dd74ef00e74392c12b67efa618a44d9b5044b..e0b89e917813f489a6788162f0a8b864ec9ade9f 100644 --- a/gtests/net/packetdrill/code.c +++ b/gtests/net/packetdrill/code.c @@ -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); } diff --git a/gtests/net/packetdrill/run.c b/gtests/net/packetdrill/run.c index 7baa7e2d02633fde97d7d7ab2fd6db8c16aba461..8a40af7bd3e06bcede947cd50815b5f7ef5ef3d5 100644 --- a/gtests/net/packetdrill/run.c +++ b/gtests/net/packetdrill/run.c @@ -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); } diff --git a/gtests/net/packetdrill/run_command.c b/gtests/net/packetdrill/run_command.c index 85c302b5e6f464c00be740f251834efb94719718..7fbaa9730f752d3056d1f44d27dc43fc39b8679f 100644 --- a/gtests/net/packetdrill/run_command.c +++ b/gtests/net/packetdrill/run_command.c @@ -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); } diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index 5f0fadb5aaff2a60dc6c10e99b81b3b041b9219a..85cb8a15782462f931fad9aaf1ba00cfc23fdd2e 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -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); }