From e6e58c96802d6611c9b4f25025a800dd4e0b75a3 Mon Sep 17 00:00:00 2001 From: noneofyourbusiness Date: Mon, 26 Sep 2022 12:07:43 +0200 Subject: libbus.c: handle fopen() errors in bus_open --- libbus.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'libbus.c') diff --git a/libbus.c b/libbus.c index 5abb4e5..b691940 100644 --- a/libbus.c +++ b/libbus.c @@ -670,6 +670,10 @@ bus_open(bus_t *restrict bus, const char *restrict file, int flags) f = fopen(file, "r"); + if (f == NULL) { + goto fail; + } + t(getline(&line, &len, f)); t(bus->key_sem = (key_t)atoll(line)); free(line), line = NULL, len = 0; @@ -684,6 +688,7 @@ bus_open(bus_t *restrict bus, const char *restrict file, int flags) t(open_semaphores(bus)); t(open_shared_memory(bus, flags)); } + return 0; fail: saved_errno = errno; -- cgit v1.2.3-70-g09d2