From bb88e38a345c90465386d9eb746ea704c7343e80 Mon Sep 17 00:00:00 2001 From: Lorenz Kästle <12514511+RincewindsHat@users.noreply.github.com> Date: Fri, 15 Nov 2024 15:10:50 +0100 Subject: check_swap stuff: Error out if meminfo file can not be opened --- plugins/check_swap.d/swap.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/plugins/check_swap.d/swap.c b/plugins/check_swap.d/swap.c index ba8c6439..2fe4544f 100644 --- a/plugins/check_swap.d/swap.c +++ b/plugins/check_swap.d/swap.c @@ -69,6 +69,13 @@ swap_result getSwapFromProcMeminfo(char proc_meminfo[]) { swap_result result = {0}; result.errorcode = STATE_UNKNOWN; + if (meminfo_file_ptr == NULL) { + // failed to open meminfo file + // errno should contain an error + result.errorcode = STATE_UNKNOWN; + return result; + } + uint64_t swap_total = 0; uint64_t swap_used = 0; uint64_t swap_free = 0; -- cgit v1.2.3-74-g34f1