trim: Fix potential buffer overrun.
trim: Fix potential buffer overrun.

This is related to the bug that was fixed previously in
b71637d9fef43f35376ab5c14d90e6c33fbf5b23. (See description.)
This could be triggered by the following input:

    0; 1; 2; 3; 4;
    0  ->  1 "g";
    1  ->  2 "b";
    2  ->  1;
    3  ->  3 "h";
    4  ->  0 "b";
    start: 4;
    end:   0;

The other fix addresses the case where the end state was larger, this
version is with the start state. Strictly speaking, the offset length
can be the max of `[max_end, max_to, start]` + 1, but it's simpler to
just use the state count, rather than attempting to save memory by
allocating a few less states if the last few are unreachable.

katef/libfsm,katef/libfsm,katef/libfsm,katef/libfsm,katef/libfsm