fix possible memory overrun