fix memory corruption when set last byte to 0