Fixup 3851 - Buffer length needs to fit size_t.max
Merge pull request #435 from AndrejMitrovic/Fixup3851

Fixup 3851 - Buffer length needs to fit size_t.max