From: Steinar H. Gunderson Date: Wed, 14 Oct 2020 21:32:02 +0000 (+0200) Subject: If plocate-build cannot open the output file, give a proper error instead of crashing. X-Git-Tag: 1.0.3~2 X-Git-Url: https://git.sesse.net/?p=plocate;a=commitdiff_plain;h=6d3b7bfd195586acbd154b9d234323e30a006f10 If plocate-build cannot open the output file, give a proper error instead of crashing. --- 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;