Skip to content

Commit

Permalink
Fix infinite loop in logger.
Browse files Browse the repository at this point in the history
When there where was more arguments then "{}" in the format string
program hanged up due to infinite loop in format function.

Signed-off-by: Łukasz Plewa <lukasz.plewa@intel.com>
  • Loading branch information
lplewa committed Oct 25, 2023
1 parent e439801 commit 887054a
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions source/common/logger/ur_sinks.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ class Sink {
<< std::endl;
}
}

if (*fmt == '\0') {
std::cerr << error_prefix
<< "Too many arguments!" << std::endl;
// ignore all left arguments and finalize message
format(buffer, fmt);
return;
}
}

format(buffer, ++fmt, std::forward<Args &&>(args)...);
Expand Down

0 comments on commit 887054a

Please sign in to comment.