Avoiding int overflow when calculating buffer size.