Thanks to The Raven and Stefan Tauner for bug report.
I fix patch for correct write buffer calculation.
Correct version of patch is attached.
--
Best regards, Alexander Irenkov