Skip to content

MunitParameterEnum with NULL value at the beginning leads to segfault #88

@slinkinone

Description

@slinkinone

MunitParameterEnum is not correctly processed by munit_suite_main. If value parameter is NULL and located at the beginning of the list it will lead to segfault.

static MunitParameterEnum test_params[] = {
  { (char*) "foo", NULL },  // NULL instead of foo_params
  { (char*) "bar", bar_params },
  { (char*) "baz", NULL },
  { NULL, NULL },
};

gdb example
run
...
Running test suite with seed 0x9e8678ec...
/example/compare                     [Detaching after fork from child process 20542]
[ OK    ] [ 0.00000232 / 0.00000146 CPU ]
/example/rand                        [Detaching after fork from child process 20543]
[ OK    ] [ 0.00000495 / 0.00000472 CPU ]
/example/parameters                  

Program received signal SIGSEGV, Segmentation fault.
0x0000555555558705 in munit_test_runner_run_test_wild ()
(gdb) bt
#0  0x0000555555558705 in munit_test_runner_run_test_wild ()
#1  0x0000555555558b78 in munit_test_runner_run_test ()
#2  0x0000555555558d45 in munit_test_runner_run_suite ()
#3  0x0000555555558e27 in munit_test_runner_run ()
#4  0x000055555555a05d in munit_suite_main_custom ()
#5  0x000055555555a255 in munit_suite_main ()
#6  0x000055555555adef in main ()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions