fix a bug on buf