fix a serious bug on buf