]> git.sesse.net Git - plocate/blobdiff - plocate-build.cpp
If plocate-build cannot open the output file, give a proper error instead of crashing.
[plocate] / 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;