Bugfix when read failed after buffer realloc