From 75cfc8eaac7d909e5cca3f892f0f9afc93ce7557 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Tue, 22 Jun 2021 18:06:04 +0200 Subject: [PATCH] Fix new watchdog timer environment check This would of course cause a segfault if the environment variable isn't defined. The regression was introduced in 8873c11e1d874a02ee942df4ff3be5ef7ae9e4c0. --- src/common/utils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/common/utils.cpp b/src/common/utils.cpp index 842e995f..59cf6323 100644 --- a/src/common/utils.cpp +++ b/src/common/utils.cpp @@ -70,7 +70,9 @@ bool is_watchdog_timer_disabled() { // This is safe because we're not storing the pointer anywhere and the // environment doesn't get modified anywhere // NOLINTNEXTLINE(concurrency-mt-unsafe) - return getenv(disable_watchdog_timer_env_var) == "1"sv; + const char* disable_watchdog_env = getenv(disable_watchdog_timer_env_var); + + return disable_watchdog_env && disable_watchdog_env == "1"sv; } bool pid_running(pid_t pid) {