fix unfinished read from buffer