From 107975c8defb4a011ec81fd37710515de38bf7fe Mon Sep 17 00:00:00 2001 From: Bartosz Taudul Date: Sun, 28 Aug 2022 14:44:41 +0200 Subject: [PATCH] Fix time rounding logic. PrintSmallInt() expects values in the 0-999 range, but the in+1 may produce 1000 here. This is invalid and it either asserted, or outputted an empty string. Workaround by simple outputting "1000" as the value here. This function is only used in context of printing time, and only in specific context. The end result will be that values like "1000 us" or "1000 ms" may appear, where they would be otherwise shortened to "1 ms" or "1 s". This may be a bit unusual, but is acceptable, as the real time value has not yet crossed the threshold required for such shortening. --- server/TracyPrint.cpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/server/TracyPrint.cpp b/server/TracyPrint.cpp index 86b01c7f..62bd8e45 100644 --- a/server/TracyPrint.cpp +++ b/server/TracyPrint.cpp @@ -117,7 +117,15 @@ static inline void PrintSmallIntFrac( char*& buf, uint64_t v ) uint64_t fr = v % 1000; if( fr >= 995 ) { - PrintSmallInt( buf, in+1 ); + if( in < 999 ) + { + PrintSmallInt( buf, in+1 ); + } + else + { + memcpy( buf, "1000", 4 ); + buf += 4; + } } else {