Fix scan-build warning.

buf_grow compares buf->cap against cap.
Fix scan-build warnings.