Skip to content

Commit

Permalink
ConsoleHandler: fix for out of bounds array access
Browse files Browse the repository at this point in the history
When using a dynamic log level, ConsoleHandler::write() needs to get
the log level by calling TransitEvent::log_level() instead of directly
accessing the log level stored in MacroMetaData.
  • Loading branch information
usefulcat authored and odygrd committed May 16, 2024
1 parent 7b6702b commit 72fe77e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions quill/src/handlers/ConsoleHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ void ConsoleHandler::write(fmt_buffer_t const& formatted_log_message, TransitEve
#if defined(_WIN32)
if (_console_colours.using_colours())
{
WORD const colour_code = _console_colours.colour_code(log_event.macro_metadata->log_level());
WORD const colour_code = _console_colours.colour_code(log_event.log_level());

// Set foreground colour and store the original attributes
WORD const orig_attribs = _set_foreground_colour(colour_code);
Expand Down Expand Up @@ -218,7 +218,7 @@ void ConsoleHandler::write(fmt_buffer_t const& formatted_log_message, TransitEve
if (_console_colours.can_use_colours())
{
// Write colour code
std::string const& colour_code = _console_colours.colour_code(log_event.macro_metadata->log_level());
std::string const& colour_code = _console_colours.colour_code(log_event.log_level());

detail::fwrite_fully(colour_code.data(), sizeof(char), colour_code.size(), _file);
}
Expand Down

0 comments on commit 72fe77e

Please sign in to comment.