From c5a1d1928d66da90a25ea2ebaf2e8e24a7db74a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Beat=20K=C3=BCng?= Date: Mon, 24 Jul 2017 19:35:47 +0200 Subject: [PATCH] px4_shutdown_unlock: check that counter is > 0 --- src/platforms/common/shutdown.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/platforms/common/shutdown.cpp b/src/platforms/common/shutdown.cpp index 0b87252fe0..772ba3aa09 100644 --- a/src/platforms/common/shutdown.cpp +++ b/src/platforms/common/shutdown.cpp @@ -66,7 +66,13 @@ int px4_shutdown_unlock() int ret = pthread_mutex_lock(&shutdown_mutex); if (ret == 0) { - --shutdown_lock_counter; + if (shutdown_lock_counter > 0) { + --shutdown_lock_counter; + + } else { + PX4_ERR("unmatched number of px4_shutdown_unlock() calls"); + } + return pthread_mutex_unlock(&shutdown_mutex); }