]> git.ipfire.org Git - thirdparty/make.git/commitdiff
[SV 62908] Don't free fifo_name twice during error handling
authorDmitry Goncharov <dgoncharov@users.sf.net>
Tue, 23 Aug 2022 01:27:08 +0000 (21:27 -0400)
committerPaul Smith <psmith@gnu.org>
Tue, 23 Aug 2022 01:27:08 +0000 (21:27 -0400)
* src/posixos.c (jobserver_setup): Set fifo_name to NULL after free.
* tests/scripts/features/jobserver: Add tests.

src/posixos.c
tests/scripts/features/jobserver

index 2629cd82c85c20661d236c7a144e0ee83a85872e..3ab487c1b98e6c7497e160e35b5f092bbdcbd554 100644 (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
         {
index 7044c51a47a22f9a18c4a25d070d84e9fcef00ec..17374eaf1da1e6097b6ea06335138a5703e236de 100644 (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;