Hi Ted,

Rajith suggested we work out what, if anything, to do for QPID-1449 on
the dev list... I think we were talking about separate patches. You
originally said you had one, but that it shouldn't be necessary
because the base issue would not really be resolved. Yesterday I
believe I resolved the base issue after the same problem showed up in
a different context. I came up with the following patch (it's also
attached to the jira). Tested on Windows ok.

The issue is that if there's 0 size for the vector, the Visual C++ C++
lib won't allocate any space, so trying to take the address of it is
invalid - this is what the range check in the C++ lib run time is
complaining about.

Do you see a problem with this patch?

Index: FieldValue.h
===================================================================
--- FieldValue.h        (revision 727451)
+++ FieldValue.h        (working copy)
@@ -193,12 +193,14 @@
     uint32_t encodedSize() const { return lenwidth + octets.size(); }

     void encode(Buffer& buffer) {
         buffer.putUInt<lenwidth>(octets.size());
-        buffer.putRawData(&octets[0], octets.size());
+        if (octets.size() > 0)
+            buffer.putRawData(&octets[0], octets.size());
     };
     void decode(Buffer& buffer) {
         uint32_t len = buffer.getUInt<lenwidth>();
         octets.resize(len);
-        buffer.getRawData(&octets[0], len);
+        if (len > 0)
+            buffer.getRawData(&octets[0], len);
     }
     bool operator==(const Data& d) const {
         const VariableWidthValue<lenwidth>* rhs = dynamic_cast< const
VariableWidthValue<lenwidth>* >(&d);

Reply via email to