[SV 62908] Don't free fifo_name twice during error handling

* src/posixos.c (jobserver_setup): Set fifo_name to NULL after free.
* tests/scripts/features/jobserver: Add tests.
This commit is contained in:
Dmitry Goncharov 2022-08-22 21:27:08 -04:00 committed by Paul Smith
parent 62da1c45e5
commit 10e130b207
2 changed files with 16 additions and 0 deletions

View file

@ -115,6 +115,7 @@ jobserver_setup (int slots, const char *style)
{
perror_with_name("jobserver mkfifo: ", fifo_name);
free (fifo_name);
fifo_name = NULL;
}
else
{

View file

@ -131,4 +131,19 @@ all a: ; @echo $@
'--jobserver-style=foo -j8',
"#MAKE#: *** Unknown jobserver auth style 'foo'. Stop.", 512);
# sv 62908.
# Test that when mkfifo fails, make switches to pipe and succeeds.
# Force mkfifo to fail by attempting to create a fifo in a non existent
# directory.
# run_make_test does not allow matching a multiline pattern, therefore run the
# test twice.
# First time look for /$ERR_no_such_file/ to ensure mkfifo failed.
# Second time look for /Nothing to be done/ to ensure make succeeded.
$ENV{TMPDIR} = "nosuchdir";
run_make_test("all:\n", '-j2', "/$ERR_no_such_file/");
$ENV{TMPDIR} = "nosuchdir";
run_make_test(undef, '-j2', "/Nothing to be done/");
1;