fix typo, protect against neg. buffer size