]> git.sesse.net Git - plocate/commitdiff
If plocate-build cannot open the output file, give a proper error instead of crashing.
authorSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 14 Oct 2020 21:32:02 +0000 (23:32 +0200)
committerSteinar H. Gunderson <steinar+git@gunderson.no>
Wed, 14 Oct 2020 22:17:40 +0000 (00:17 +0200)
plocate-build.cpp

index 1571a77e8dacf57d6b2b0496a2073a4fdfff3e5b..2093ab2010578109eb4dd02412a9a037edc7ea19 100644 (file)
@@ -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;