handle 0-length buffers