IO-356 Fix infinite loop; check that buffer size is large enough to hold any character in the charset

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/io/trunk@1470351 13f79535-47bb-0310-9956-ffa450edef68