From 28f884ee81c047769fb3e7b39411a455f00dd8e9 Mon Sep 17 00:00:00 2001 From: Donat Zenichev Date: Tue, 19 May 2026 21:19:57 +0200 Subject: [PATCH] MT#59962 AmSession: `session_stopped()` decrement guard If stop bookkeeping is ever called twice or without a successful start, it wraps to a huge value, because the `session_num` is `unsigned int`. Just a guard and throw a warning accordingly, when 0 is reached. Change-Id: Ic9cef4aa7ae827fc8ce68808a2e6f5753697ebbb --- core/AmSession.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/AmSession.cpp b/core/AmSession.cpp index 94024ccb..a12d64a8 100644 --- a/core/AmSession.cpp +++ b/core/AmSession.cpp @@ -614,8 +614,12 @@ void AmSession::session_stopped() { timersub(&now, &avg_last_timestamp, &delta); avg_session_num = avg_session_num + (session_num * (delta.tv_sec * 1000000ULL + delta.tv_usec)); avg_last_timestamp = now; - //current session number - session_num = session_num - 1; + + if (session_num > 0) + --session_num; + else + WARN("AmSession::session_stopped() cannot decrement more! sessions counter is 0 already.\n"); + session_num_mut.unlock(); __update_session_count(getSessionNum());