fix list index overflow

This is visible on https://en.wikipedia.org/wiki/Obama, which has an ordered list with more than 256 items
This commit is contained in:
stasoid 2022-04-05 21:24:41 +06:00
parent 63014557d7
commit 9e34db38f2
2 changed files with 4 additions and 4 deletions

View File

@ -14,17 +14,17 @@ int litehtml::el_li::render(int x, int y, int max_width, bool second_pass)
{
const auto hasStart = p->get_attr(_t("start"));
const int start = hasStart ? t_atoi(hasStart) : 1;
tchar_t val[2] = { (tchar_t)start, 0 };
int val = start;
for (int i = 0, n = (int)p->get_children_count(); i < n; ++i)
{
auto child = p->get_child(i);
if (child.get() == this)
{
set_attr(_t("list_index"), val);
set_attr(_t("list_index"), t_to_string(val).c_str());
break;
}
else if (!t_strcmp(child->get_tagName(), _t("li")))
++val[0];
++val;
}
}

View File

@ -2969,7 +2969,7 @@ void litehtml::html_tag::draw_list_marker( uint_ptr hdc, const position &pos )
{
lm.pos.y = pos.y;
lm.pos.height = pos.height;
lm.index = (unsigned char) get_attr(_t("list_index"), _t(""))[0];
lm.index = t_atoi(get_attr(_t("list_index"), _t("0")));
}
else
{