fix possible buffer overrun asserts