diff options
author | Gordon Sim <gsim@apache.org> | 2008-03-31 18:01:31 +0000 |
---|---|---|
committer | Gordon Sim <gsim@apache.org> | 2008-03-31 18:01:31 +0000 |
commit | 50b5c480e3960505e7d9e7adf765ad63af5c9fda (patch) | |
tree | 5ee52e5c0564e2656bfa27154bbd2dc8dd2317c6 /cpp/src | |
parent | 9649f8ccca2a9f62a946bd58e7d3e8cb60031232 (diff) | |
download | qpid-python-50b5c480e3960505e7d9e7adf765ad63af5c9fda.tar.gz |
Allow zero sized arrays (with no typecode or count)
git-svn-id: https://svn.apache.org/repos/asf/incubator/qpid/trunk/qpid@643086 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp/src')
-rw-r--r-- | cpp/src/qpid/framing/Array.cpp | 36 |
1 files changed, 19 insertions, 17 deletions
diff --git a/cpp/src/qpid/framing/Array.cpp b/cpp/src/qpid/framing/Array.cpp index d2ab354dab..71281c7a52 100644 --- a/cpp/src/qpid/framing/Array.cpp +++ b/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)); - } } |