summaryrefslogtreecommitdiff
path: root/qpid/cpp/src
diff options
context:
space:
mode:
authorGordon Sim <gsim@apache.org>2008-03-31 18:01:31 +0000
committerGordon Sim <gsim@apache.org>2008-03-31 18:01:31 +0000
commitdec0c1bc8f2971905e75c32a821f153d524b8d34 (patch)
tree01e84f542d315332e70f3729b21507c2cfe66714 /qpid/cpp/src
parentc18e3f80a26555ead0203ac4f86ff054a6c2ce02 (diff)
downloadqpid-python-dec0c1bc8f2971905e75c32a821f153d524b8d34.tar.gz
Allow zero sized arrays (with no typecode or count)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk@643086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'qpid/cpp/src')
-rw-r--r--qpid/cpp/src/qpid/framing/Array.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/qpid/cpp/src/qpid/framing/Array.cpp b/qpid/cpp/src/qpid/framing/Array.cpp
index d2ab354dab..71281c7a52 100644
--- a/qpid/cpp/src/qpid/framing/Array.cpp
+++ b/qpid/cpp/src/qpid/framing/Array.cpp
@@ -80,24 +80,26 @@ void Array::decode(Buffer& buffer){
throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected "
<< size << " bytes but only " << available << " available"));
}
- typeOctet = buffer.getOctet();
- uint32_t count = buffer.getLong();
-
- FieldValue dummy;
- dummy.setType(typeOctet);
- available = buffer.available();
- if (available < count * dummy.getData().size()) {
- throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected "
- << count << " items of " << dummy.getData().size()
- << " bytes each but only " << available << " bytes available"));
+ if (size) {
+ typeOctet = buffer.getOctet();
+ uint32_t count = buffer.getLong();
+
+ FieldValue dummy;
+ dummy.setType(typeOctet);
+ available = buffer.available();
+ if (available < count * dummy.getData().size()) {
+ throw SyntaxErrorException(QPID_MSG("Not enough data for array, expected "
+ << count << " items of " << dummy.getData().size()
+ << " bytes each but only " << available << " bytes available"));
+ }
+
+ for (uint32_t i = 0; i < count; i++) {
+ ValuePtr value(new FieldValue);
+ value->setType(typeOctet);
+ value->getData().decode(buffer);
+ values.push_back(ValuePtr(value));
+ }
}
-
- for (uint32_t i = 0; i < count; i++) {
- ValuePtr value(new FieldValue);
- value->setType(typeOctet);
- value->getData().decode(buffer);
- values.push_back(ValuePtr(value));
- }
}