1
1
mirror of https://github.com/tstack/lnav.git synced 2024-10-26 21:19:54 +03:00

[view_curses] check color

Related to #1245
This commit is contained in:
Tim Stack 2024-03-31 06:40:21 -07:00
parent 3a63791b22
commit a2b573aa58
4 changed files with 14 additions and 8 deletions

View File

@ -323,7 +323,10 @@ scrub_ansi_string(std::string& str, string_attrs_t* sa)
semi_pred); semi_pred);
auto color_index = scn::scan_value<short>( auto color_index = scn::scan_value<short>(
color_index_pair.first.to_string_view()); color_index_pair.first.to_string_view());
if (!color_index.has_value()) { if (!color_index.has_value()
|| color_index.value() < 0
|| color_index.value() > 255)
{
break; break;
} }
if (ansi_code == 38) { if (ansi_code == 38) {

View File

@ -14,7 +14,7 @@ default = []
# We produce both of these at the moment, but could consider refining this. ref # We produce both of these at the moment, but could consider refining this. ref
# https://github.com/rust-lang/cargo/issues/8607 & # https://github.com/rust-lang/cargo/issues/8607 &
# https://github.com/rust-lang/rust/issues/59302 # https://github.com/rust-lang/rust/issues/59302
crate_type = ["staticlib", "cdylib"] crate_type = ["staticlib"]
doctest = false doctest = false
test = false test = false
doc = false doc = false

View File

@ -1766,7 +1766,7 @@ __inline__ static void trap_instruction(void)
/* Known problem: /* Known problem:
* Same problem and workaround as Thumb mode */ * Same problem and workaround as Thumb mode */
} }
#elif defined(__aarch64__) && defined(__APPLE__) #elif defined(__aarch64__) && defined(__APPLE__) && defined(__clang__)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_BULTIN_DEBUGTRAP
#elif defined(__aarch64__) #elif defined(__aarch64__)
#define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION #define DEBUG_BREAK_IMPL DEBUG_BREAK_USE_TRAP_INSTRUCTION

View File

@ -430,14 +430,17 @@ view_curses::mvwattrline(WINDOW* window,
short cur_fg, cur_bg; short cur_fg, cur_bg;
pair_content(cur_pair, &cur_fg, &cur_bg); pair_content(cur_pair, &cur_fg, &cur_bg);
if (fg_color[lpc] != -1 && bg_color[lpc] == -1 if (fg_color[lpc] >= 0
&& base_attrs.ta_bg_color.value_or(0) >= 0) && fg_color[lpc] < view_colors::vc_active_palette->tc_palette.size()
&& bg_color[lpc] == -1 && base_attrs.ta_bg_color.value_or(0) >= 0
&& base_attrs.ta_bg_color.value_or(0)
< view_colors::vc_active_palette->tc_palette.size())
{ {
const auto& fg_color_info const auto& fg_color_info
= view_colors::vc_active_palette->tc_palette[fg_color[lpc]]; = view_colors::vc_active_palette->tc_palette.at(fg_color[lpc]);
const auto& bg_color_info const auto& bg_color_info
= view_colors::vc_active_palette = view_colors::vc_active_palette->tc_palette.at(
->tc_palette[base_attrs.ta_bg_color.value_or(0)]; base_attrs.ta_bg_color.value_or(0));
if (!fg_color_info.xc_lab_color.sufficient_contrast( if (!fg_color_info.xc_lab_color.sufficient_contrast(
bg_color_info.xc_lab_color)) bg_color_info.xc_lab_color))