Fix a long standing  bug in the output buffer size computation.

git cherry-pick -e 2a7f2ae7d4b25f89e36be04e47b9e7a3d76e0cfd
1 file changed