widget: Fix off-by-one in allowed palette size.
widget: Don't try to allocate arbitrary amount of memory.