summaryrefslogtreecommitdiff
path: root/cpp/src/Ice/BasicStream.cpp
diff options
context:
space:
mode:
authorMichi Henning <michi@zeroc.com>2003-05-22 23:08:12 +0000
committerMichi Henning <michi@zeroc.com>2003-05-22 23:08:12 +0000
commitb44a7dace4ee7545b0345a06ad4d674d125ecaa2 (patch)
tree858894810a68a644e8470c74fe48d6c49e6e0aac /cpp/src/Ice/BasicStream.cpp
parentminor edit (diff)
downloadice-b44a7dace4ee7545b0345a06ad4d674d125ecaa2.tar.bz2
ice-b44a7dace4ee7545b0345a06ad4d674d125ecaa2.tar.xz
ice-b44a7dace4ee7545b0345a06ad4d674d125ecaa2.zip
Fixed a bug that caused a crash if an empty sequence of classes was
marshaled.
Diffstat (limited to 'cpp/src/Ice/BasicStream.cpp')
-rw-r--r--cpp/src/Ice/BasicStream.cpp41
1 files changed, 22 insertions, 19 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp
index ec9d6fdadb0..6470572218e 100644
--- a/cpp/src/Ice/BasicStream.cpp
+++ b/cpp/src/Ice/BasicStream.cpp
@@ -1261,30 +1261,33 @@ IceInternal::BasicStream::throwException()
void
BasicStream::writePendingObjects()
{
- while(_currentWriteEncaps->toBeMarshaledMap->size())
+ if(_currentWriteEncaps && _currentWriteEncaps->toBeMarshaledMap)
{
- PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
- writeSize(static_cast<Int>(savedMap.size()));
- for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
+ while(_currentWriteEncaps->toBeMarshaledMap->size())
{
+ PtrToIndexMap savedMap = *_currentWriteEncaps->toBeMarshaledMap;
+ writeSize(static_cast<Int>(savedMap.size()));
+ for(PtrToIndexMap::iterator p = savedMap.begin(); p != savedMap.end(); ++p)
+ {
+ //
+ // Add an instance from the old to-be-marshaled map to the marshaled map and then
+ // ask the instance to marshal itself. Any new class instances that are triggered
+ // by the classes marshaled are added to toBeMarshaledMap.
+ //
+ _currentWriteEncaps->marshaledMap->insert(*p);
+ writeInstance(p->first, p->second);
+ }
+
//
- // Add an instance from the old to-be-marshaled map to the marshaled map and then
- // ask the instance to marshal itself. Any new class instances that are triggered
- // by the classes marshaled are added to toBeMarshaledMap.
+ // We have marshaled all the instances for this pass, substract what we have
+ // marshaled from the toBeMarshaledMap.
//
- _currentWriteEncaps->marshaledMap->insert(*p);
- writeInstance(p->first, p->second);
+ PtrToIndexMap newMap;
+ set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(), _currentWriteEncaps->toBeMarshaledMap->end(),
+ savedMap.begin(), savedMap.end(),
+ insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
+ *_currentWriteEncaps->toBeMarshaledMap = newMap;
}
-
- //
- // We have marshaled all the instances for this pass, substract what we have
- // marshaled from the toBeMarshaledMap.
- //
- PtrToIndexMap newMap;
- set_difference(_currentWriteEncaps->toBeMarshaledMap->begin(), _currentWriteEncaps->toBeMarshaledMap->end(),
- savedMap.begin(), savedMap.end(),
- insert_iterator<PtrToIndexMap>(newMap, newMap.begin()));
- *_currentWriteEncaps->toBeMarshaledMap = newMap;
}
writeSize(0); // Zero marker indicates end of sequence of sequences of instances.
}