- Check the loop termination in readBytes() properly: currently it increments totalBytesRead while also decrementing nBytesToRead, so when compared to each other, the loop terminates when the buffer is half full. Only check for nBytesToRead instead. - Deal with the possibility of available() returning 0 in readSomeBytes(). Patch by: me Cherry-picked from https://github.com/apache/openoffice/commit/7e29bacc90c4b1b9788c3b71dfacd17daecde7a7 "Fix some errors in the scripting module's XInputStreamImpl:" Change-Id: I951dc10565afa3519b0ddf98de559a7b585b1627 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149156 Reviewed-by: Stephan Bergmann <sbergman@redhat.com> Tested-by: Jenkins