From 6d3b7bfd195586acbd154b9d234323e30a006f10 Mon Sep 17 00:00:00 2001 From: "Steinar H. Gunderson" Date: Wed, 14 Oct 2020 23:32:02 +0200 Subject: [PATCH] If plocate-build cannot open the output file, give a proper error instead of crashing. --- plocate-build.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/plocate-build.cpp b/plocate-build.cpp index 1571a77..2093ab2 100644 --- a/plocate-build.cpp +++ b/plocate-build.cpp @@ -480,6 +480,10 @@ void do_build(const char *infile, const char *outfile, int block_size) umask(0027); FILE *outfp = fopen(outfile, "wb"); + if (outfp == nullptr) { + perror(outfile); + exit(1); + } // Write the header. Header hdr; -- 2.39.2