regression from 8f82979d8af920415bce2f9e9e3cb84cdc0ca682 using wrong values to calculate buffer size