diff options
author | Michi Henning <michi@zeroc.com> | 2009-01-29 12:31:11 +1000 |
---|---|---|
committer | Michi Henning <michi@zeroc.com> | 2009-01-29 12:31:11 +1000 |
commit | b792f42a8d1f3b01bb57988a0610d3b34fa86b00 (patch) | |
tree | b469718a6f4664a495048653ec8526e6fb4f8690 /java/src/IceInternal/BasicStream.java | |
parent | Fixed bug 3615 - bogus computation for delay (Ticks is in 100 of ns not in ms) (diff) | |
download | ice-b792f42a8d1f3b01bb57988a0610d3b34fa86b00.tar.bz2 ice-b792f42a8d1f3b01bb57988a0610d3b34fa86b00.tar.xz ice-b792f42a8d1f3b01bb57988a0610d3b34fa86b00.zip |
Squashed commit of the following:
commit 20d8f03d5e8caffb3d75a661734a77d767f8def1
Author: Michi Henning <michi@zeroc.com>
Date: Thu Jan 29 12:29:34 2009 +1000
Bug 3547: Object unmarshaling code not safe?
Diffstat (limited to 'java/src/IceInternal/BasicStream.java')
-rw-r--r-- | java/src/IceInternal/BasicStream.java | 59 |
1 files changed, 38 insertions, 21 deletions
diff --git a/java/src/IceInternal/BasicStream.java b/java/src/IceInternal/BasicStream.java index ae39f1055bb..d320bd0062f 100644 --- a/java/src/IceInternal/BasicStream.java +++ b/java/src/IceInternal/BasicStream.java @@ -1377,33 +1377,41 @@ public class BasicStream int index = readInt(); - if(index == 0) + if(patcher != null) { - patcher.patch(null); - return; - } + if(index == 0) + { + // No need to call the patch function--the reference is default-initialized to null anyway. + // patcher.patch(null); + return; + } - if(index < 0 && patcher != null) - { - Integer i = new Integer(-index); - java.util.LinkedList<Patcher> patchlist = _readEncapsStack.patchMap.get(i); - if(patchlist == null) + if(index < 0) { + Integer i = new Integer(-index); + java.util.LinkedList<Patcher> patchlist = _readEncapsStack.patchMap.get(i); + if(patchlist == null) + { + // + // We have no outstanding instances to be patched for + // this index, so make a new entry in the patch map. + // + patchlist = new java.util.LinkedList<Patcher>(); + _readEncapsStack.patchMap.put(i, patchlist); + } // - // We have no outstanding instances to be patched for - // this index, so make a new entry in the patch map. + // Append a patcher for this instance and see if we can + // patch the instance. (The instance may have been + // unmarshaled previously.) // - patchlist = new java.util.LinkedList<Patcher>(); - _readEncapsStack.patchMap.put(i, patchlist); + patchlist.add(patcher); + patchReferences(null, i); + return; } - // - // Append a patcher for this instance and see if we can - // patch the instance. (The instance may have been - // unmarshaled previously.) - // - patchlist.add(patcher); - patchReferences(null, i); - return; + } + if(index < 0) + { + throw new Ice.MarshalException("Invalid class instance index"); } String mostDerivedId = readTypeId(); @@ -1636,6 +1644,15 @@ public class BasicStream } while(num > 0); + if(_readEncapsStack != null && _readEncapsStack.patchMap != null && _readEncapsStack.patchMap.size() != 0) + { + // + // If any entries remain in the patch map, the sender has sent an index for an object, but failed + // to supply the object. + // + throw new Ice.MarshalException("Index for class received, but no instance"); + } + // // Iterate over unmarshaledMap and invoke ice_postUnmarshal on // each object. We must do this after all objects in this |