diff options
author | Mark Spruiell <mes@zeroc.com> | 2009-02-09 15:19:01 -0800 |
---|---|---|
committer | Mark Spruiell <mes@zeroc.com> | 2009-02-09 15:19:01 -0800 |
commit | 7e95997eab01e00a165b7b2bb218504c693da725 (patch) | |
tree | c70c767ba9fad26fcf6de3dd5ac19917d5c641ee /cpp/src/Ice/BasicStream.cpp | |
parent | Add other official patchs in REAME (diff) | |
download | ice-7e95997eab01e00a165b7b2bb218504c693da725.tar.bz2 ice-7e95997eab01e00a165b7b2bb218504c693da725.tar.xz ice-7e95997eab01e00a165b7b2bb218504c693da725.zip |
bug 3576 - stream operations should raise exceptions instead of crash
Diffstat (limited to 'cpp/src/Ice/BasicStream.cpp')
-rw-r--r-- | cpp/src/Ice/BasicStream.cpp | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/cpp/src/Ice/BasicStream.cpp b/cpp/src/Ice/BasicStream.cpp index 118b790f16a..c85e1d20b56 100644 --- a/cpp/src/Ice/BasicStream.cpp +++ b/cpp/src/Ice/BasicStream.cpp @@ -291,6 +291,26 @@ IceInternal::BasicStream::ReadEncaps::swap(ReadEncaps& other) std::swap(previous, other.previous); } +void +IceInternal::BasicStream::endWriteEncapsChecked() +{ + if(!_currentWriteEncaps) + { + throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation"); + } + endWriteEncaps(); +} + +void +IceInternal::BasicStream::endReadEncapsChecked() +{ + if(!_currentReadEncaps) + { + throw EncapsulationException(__FILE__, __LINE__, "not in an encapsulation"); + } + endReadEncaps(); +} + Int IceInternal::BasicStream::getReadEncapsSize() { @@ -377,6 +397,14 @@ IceInternal::BasicStream::skipSlice() void IceInternal::BasicStream::writeTypeId(const string& id) { + if(!_currentWriteEncaps || !_currentWriteEncaps->typeIdMap) + { + // + // write(ObjectPtr) must be called first. + // + throw MarshalException(__FILE__, __LINE__, "type ids require an encapsulation"); + } + TypeIdWriteMap::const_iterator k = _currentWriteEncaps->typeIdMap->find(id); if(k != _currentWriteEncaps->typeIdMap->end()) { @@ -394,6 +422,14 @@ IceInternal::BasicStream::writeTypeId(const string& id) void IceInternal::BasicStream::readTypeId(string& id) { + if(!_currentReadEncaps || !_currentReadEncaps->typeIdMap) + { + // + // read(PatchFunc, void*) must be called first. + // + throw MarshalException(__FILE__, __LINE__, "type ids require an encapsulation"); + } + bool isIndex; read(isIndex); if(isIndex) |