File tree Expand file tree Collapse file tree 1 file changed +15
-5
lines changed
Expand file tree Collapse file tree 1 file changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -60,8 +60,11 @@ RuntimeError& error_from_ref(RuntimeErrorRef ref)
6060RuntimeErrorRef runtime_error_f (const char * format, ...)
6161{
6262 int i = 0 ;
63- bool expected = false ;
64- while (gErrorBooking [i].compare_exchange_strong (expected, true ) == false ) {
63+ while (true ) {
64+ bool expected = false ;
65+ if (gErrorBooking [i].compare_exchange_strong (expected, true ) == false ) {
66+ break ;
67+ }
6568 ++i;
6669 if (i >= RuntimeError::MAX_RUNTIME_ERRORS) {
6770 throw std::runtime_error (" Too many o2::framework::runtime_error thrown without proper cleanup." );
@@ -78,11 +81,18 @@ RuntimeErrorRef runtime_error_f(const char* format, ...)
7881RuntimeErrorRef runtime_error (const char * s)
7982{
8083 int i = 0 ;
81- bool expected = false ;
82- while (gErrorBooking [i].compare_exchange_strong (expected, true ) == false ) {
84+ while (true ) {
85+ bool expected = false ;
86+ if (gErrorBooking [i].compare_exchange_strong (expected, true ) == false ) {
87+ break ;
88+ }
8389 ++i;
90+ if (i >= RuntimeError::MAX_RUNTIME_ERRORS) {
91+ throw std::runtime_error (" Too many o2::framework::runtime_error thrown without proper cleanup." );
92+ }
8493 }
85- strncpy (gError [i].what , s, RuntimeError::MAX_RUNTIME_ERROR_SIZE);
94+ strncpy (gError [i].what , s, RuntimeError::MAX_RUNTIME_ERROR_SIZE - 1 );
95+ gError [i].what [RuntimeError::MAX_RUNTIME_ERROR_SIZE - 1 ] = 0 ;
8696 gError [i].maxBacktrace = canDumpBacktrace () ? backtrace (gError [i].backtrace , BacktraceHelpers::MAX_BACKTRACE_SIZE) : 0 ;
8797 return RuntimeErrorRef{i};
8898}
You can’t perform that action at this time.
0 commit comments