summaryrefslogtreecommitdiff
path: root/scripting
diff options
context:
space:
mode:
Diffstat (limited to 'scripting')
-rw-r--r--scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java12
1 files changed, 9 insertions, 3 deletions
diff --git a/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
index 8320b6227cdb..3270d40d5bfb 100644
--- a/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
+++ b/scripting/java/com/sun/star/script/framework/io/XInputStreamImpl.java
@@ -41,11 +41,16 @@ public class XInputStreamImpl implements XInputStream {
try {
int bytesRead;
- while ((bytesRead = is.read(aData[ 0 ], totalBytesRead, nBytesToRead)) > 0
- && (totalBytesRead < nBytesToRead)) {
+ while (( nBytesToRead > 0 ) && (bytesRead = is.read(aData[ 0 ], totalBytesRead, nBytesToRead)) > 0) {
totalBytesRead += bytesRead;
nBytesToRead -= bytesRead;
}
+ if ( totalBytesRead < aData[ 0 ].length )
+ {
+ byte[] out = new byte[ totalBytesRead ];
+ System.arraycopy( aData[ 0 ], 0, out, 0, totalBytesRead );
+ aData[ 0 ] = out;
+ }
} catch (IOException e) {
throw new com.sun.star.io.IOException(e);
} catch (IndexOutOfBoundsException aie) {
@@ -62,7 +67,8 @@ public class XInputStreamImpl implements XInputStream {
int bytesToRead = nMaxBytesToRead;
int availableBytes = available();
- if (availableBytes < nMaxBytesToRead) {
+ if (0 < availableBytes && availableBytes < nMaxBytesToRead)
+ {
bytesToRead = availableBytes;
}