nooc

Unnamed repository; edit this file 'description' to name the repository.
git clone git://git.nihaljere.xyz/nooc
Log | Files | Refs | LICENSE

commit 426dea56758255ad86a69a6b931b3332c8d2405c
parent 9d361b97dafc7bbda101f48a4ebd7edb97c796d2
Author: Nihal Jere <nihal@nihaljere.xyz>
Date:   Tue,  7 Dec 2021 11:57:43 -0600

error check on mmap

Diffstat:
Mmain.c | 4++++
1 file changed, 4 insertions(+), 0 deletions(-)

diff --git a/main.c b/main.c @@ -696,6 +696,10 @@ main(int argc, char *argv[]) char *addr = mmap(NULL, statbuf.st_size, PROT_READ, MAP_PRIVATE, in, 0); close(in); + if (addr == NULL) { + fprintf(stderr, "failed to map input file into memory\n"); + return 1; + } struct token *head = lex((struct slice){statbuf.st_size, statbuf.st_size, addr}); struct token *curtoken = head;