This is the user space fix for launchpad.net/busgs/599450

It changes the table resizing so that there is always sufficient
high entries in the table, preventing bounds violations from
occurring.

Previously the resize allocation was always based on the character
set range for a state, which could be more or less than actually
required, and packing would waste some space when over allocation
was done.

As a result this patch in general results in slightly smaller
transition tables even though it enforcing the minimum required
padding to avoid bounds violations.
This commit is contained in:
John Johansen 2010-07-23 04:30:31 +02:00
parent bfb96638f6
commit 837f47c921

View file

@ -2147,11 +2147,11 @@ repeat:
x = free_list[x].second;
}
if (!x) {
resize = cases.cases.rbegin()->first - cases.begin()->first + 1;
resize = 256 - cases.begin()->first;
x = free_list.size();
/* set prev to last free */
} else if (x + cases.cases.rbegin()->first + 1 - cases.begin()->first > next_check.size()) {
resize = cases.cases.rbegin()->first + 1;
} else if (x + 255 - cases.begin()->first >= next_check.size()) {
resize = (255 - cases.begin()->first - (next_check.size() - 1 - x));
for (size_t y = x; y; y = free_list[y].second)
prev = y;
}