Skip to content

Commit

Permalink
Fix segfault when msg_printer_destroy in called in the exit callback
Browse files Browse the repository at this point in the history
  • Loading branch information
BlockoS committed May 19, 2024
1 parent 409071a commit e57ca51
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions cli/etripator.c
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,9 @@ int label_output(cli_opt_t *option, label_repository_t *repository) {
return 1;
}

static console_msg_printer_t g_console_printer;
static file_msg_printer_t g_file_printer;

/* ---------------------------------------------------------------- */
int main(int argc, const char **argv) {
cli_opt_t option;
Expand All @@ -117,9 +120,6 @@ int main(int argc, const char **argv) {
int i;
int ret, failure;

console_msg_printer_t console_printer;
file_msg_printer_t file_printer;

memmap_t map;

section_t *section;
Expand All @@ -129,14 +129,14 @@ int main(int argc, const char **argv) {

msg_printer_init();

file_msg_printer_init(&file_printer);
console_msg_printer_init(&console_printer);
file_msg_printer_init(&g_file_printer);
console_msg_printer_init(&g_console_printer);

if (msg_printer_add(&file_printer.super)) {
if (msg_printer_add(&g_file_printer.super)) {
fprintf(stderr, "Failed to setup file printer.\n");
return EXIT_FAILURE;
}
if (msg_printer_add(&console_printer.super)) {
if (msg_printer_add(&g_console_printer.super)) {
fprintf(stderr, "Failed to setup console printer.\n");
return EXIT_FAILURE;
}
Expand Down

0 comments on commit e57ca51

Please sign in to comment.