summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-13 22:19:44 +0200
committerLieuwe Rooijakkers <lieuwerooijakkers@gmail.com>2024-07-13 22:19:44 +0200
commitbe8ba89d09ada245e458ae006f477ff720d21fd1 (patch)
treeffb948e00941c2a7bc3f1c9442daf3a8f9fff10c
parent57c7abbd3c3b30086a5503a8017748caaf47084c (diff)
kat, tak: handle open_map errors
-rw-r--r--src/kat.c3
-rw-r--r--src/tak.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/src/kat.c b/src/kat.c
index 9c50aed..551a43d 100644
--- a/src/kat.c
+++ b/src/kat.c
@@ -19,6 +19,9 @@ int entry_kat(int argc, char **argv) {
for (int i = 1; i < argc; i++) {
const char *fname = argv[i];
struct map *map = open_map(fname);
+ if (map == NULL) {
+ return 1;
+ }
for (size_t i = 0; i < map->sb.st_size; i++) {
putchar(map->addr[i]);
diff --git a/src/tak.c b/src/tak.c
index caf1837..06fc35e 100644
--- a/src/tak.c
+++ b/src/tak.c
@@ -19,6 +19,9 @@ int entry_tak(int argc, char **argv) {
for (int i = argc-1; i >= 1; i--) {
const char *fname = argv[i];
struct map *map = open_map(fname);
+ if (map == NULL) {
+ return 1;
+ }
char *lstart, *lend;
lend = &map->addr[map->sb.st_size - 1];