protect against negative buffer size