Update buffer.c

fix bug...
Merge pull request #1 from uniskz/patch-1

Update buffer.c