Curses: don't iterate through unbound COLORS #369

On DirectColor-capable terminals with the proper terminfo
database in use, COLORS is 2^24. Since the color map is
only 64k entries, this resulted in a segfault. I've
introduced NC::colorCount(), which bounds it by the
previously assumed maximum (and usable range) of 256.
This commit is contained in:
nick black
2020-01-07 18:41:04 -05:00
parent 31ee76e8ee
commit 302bcca99a
3 changed files with 24 additions and 4 deletions

View File

@@ -424,8 +424,10 @@ void write_bindings(NC::Scrollpad &w)
}
section(w, "", "List of available colors");
for (int i = 0; i < COLORS; ++i)
for (int i = 0; i < NC::colorCount(); ++i)
{
w << NC::Color(i, NC::Color::transparent) << i+1 << NC::Color::End << " ";
}
}
}