check for MAP_FAILED result

This commit is contained in:
asvitkine 2011-12-27 20:50:27 +00:00
parent b48405744e
commit 521da856b5

View File

@ -166,7 +166,7 @@ main(int argc, const char *argv[])
*/ */
addr = mmap(NULL, file_size, PROT_READ | PROT_WRITE, addr = mmap(NULL, file_size, PROT_READ | PROT_WRITE,
MAP_FILE | MAP_SHARED, fd, 0); MAP_FILE | MAP_SHARED, fd, 0);
if (addr == NULL) { if (addr == NULL || addr == MAP_FAILED) {
(void)fprintf(stderr, "%s: could not mmap %s: %s\n", (void)fprintf(stderr, "%s: could not mmap %s: %s\n",
progname, filename, strerror(errno)); progname, filename, strerror(errno));
exit(1); exit(1);