diff options
Diffstat (limited to 'java/src')
-rw-r--r-- | java/src/Ice/InputStreamI.java | 2 | ||||
-rw-r--r-- | java/src/Ice/OutputStreamI.java | 7 | ||||
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 38 |
3 files changed, 45 insertions, 2 deletions
diff --git a/java/src/Ice/InputStreamI.java b/java/src/Ice/InputStreamI.java index 9ee2c868b4a..cbed1636c37 100644 --- a/java/src/Ice/InputStreamI.java +++ b/java/src/Ice/InputStreamI.java @@ -225,7 +225,7 @@ public class InputStreamI implements InputStream public void endEncapsulation() { - _is.endReadEncaps(); + _is.endReadEncapsChecked(); } public void diff --git a/java/src/Ice/OutputStreamI.java b/java/src/Ice/OutputStreamI.java index 934f8047e85..7cd54936769 100644 --- a/java/src/Ice/OutputStreamI.java +++ b/java/src/Ice/OutputStreamI.java @@ -136,6 +136,11 @@ public class OutputStreamI implements OutputStream public void writeSize(int sz) { + if(sz < 0) + { + throw new NegativeSizeException(); + } + _os.writeSize(sz); } @@ -184,7 +189,7 @@ public class OutputStreamI implements OutputStream public void endEncapsulation() { - _os.endWriteEncaps(); + _os.endWriteEncapsChecked(); } public void diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index 659995acc2a..2541478d1d6 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -367,6 +367,17 @@ public class BasicStream } public void + endWriteEncapsChecked() // Used by public stream API. + { + if(_writeEncapsStack == null) + { + throw new Ice.EncapsulationException("not in an encapsulation"); + } + + endWriteEncaps(); + } + + public void startReadEncaps() { { @@ -478,6 +489,17 @@ public class BasicStream } } + public void + endReadEncapsChecked() // Used by public stream API. + { + if(_readEncapsStack == null) + { + throw new Ice.EncapsulationException("not in an encapsulation"); + } + + endReadEncaps(); + } + public int getReadEncapsSize() { @@ -592,6 +614,14 @@ public class BasicStream public void writeTypeId(String id) { + if(_writeEncapsStack == null || _writeEncapsStack.typeIdMap == null) + { + // + // writeObject() must be called first. + // + throw new Ice.MarshalException("type ids require an encapsulation"); + } + Integer index = _writeEncapsStack.typeIdMap.get(id); if(index != null) { @@ -610,6 +640,14 @@ public class BasicStream public String readTypeId() { + if(_readEncapsStack == null || _readEncapsStack.typeIdMap == null) + { + // + // readObject() must be called first. + // + throw new Ice.MarshalException("type ids require an encapsulation"); + } + String id; Integer index; final boolean isIndex = readBool(); |