Fix buffer size computation