bugfix: need_flush check error in buffer