From 956d90f8cb5e5324c405ef3405b45a34d9c41d29 Mon Sep 17 00:00:00 2001 From: mio Date: Sat, 28 Sep 2024 22:38:37 +1000 Subject: [PATCH] Fix unsigned overflow in Debug::Block dtor Signed-off-by: mio --- amarok/src/debug.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/amarok/src/debug.h b/amarok/src/debug.h index 6fe48cc0..d212f9fe 100644 --- a/amarok/src/debug.h +++ b/amarok/src/debug.h @@ -194,7 +194,10 @@ namespace Debug LIBAMAROK_EXPORT double duration = double(end.tv_sec) + (double(end.tv_usec) / 1000000.0); - Debug::modifieableIndent().truncate( Debug::indent().length() - 2 ); + // Prevent overflow that causes UINT_MAX allocation. + uint newLength = (Debug::indent().length() < 2) ? 0 : (Debug::indent().length() - 2); + Debug::modifieableIndent().truncate( newLength ); + kdDebug() << "END__: " << m_label << " - Took " << TQString::number( duration, 'g', 2 ) << "s\n"; mutex.unlock();