Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java')
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java18
1 files changed, 16 insertions, 2 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
index 9814e3c4fc..f2e5670da4 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/util/stream/ExtendedDataInputStream.java
@@ -32,8 +32,22 @@ public class ExtendedDataInputStream extends DataInputStream implements Extended
throw new IndexOutOfBoundsException();
}
- byte[] b = new byte[length];
- read(b);
+ byte[] b;
+ try
+ {
+ b = new byte[length];
+ }
+ catch (Throwable t)
+ {
+ throw new IOException("Unable to allocate " + length + " bytes");
+ }
+
+ int bytes = read(b);
+ if (bytes != length)
+ {
+ throw new IOException("Unable to read " + length + " bytes (after " + bytes + " bytes)");
+ }
+
return b;
}

Back to the top