C++ test for InlineVector tries to take address of invalid byte
---------------------------------------------------------------
Key: QPID-1960
URL: https://issues.apache.org/jira/browse/QPID-1960
Project: Qpid
Issue Type: Bug
Affects Versions: 0.5
Reporter: Steve Huston
Fix For: 0.6
The qpid/src/tests/InlineVector.cpp test isInline() tester works by taking
address of element 0 and comparing it to various things. However, if the
InlineVector has no storage allocated yet, taking the address of element 0 is
invalid. In this case, Windows Visual Studio throws an out-of-range exception.
This fixes it:
Index: src/tests/InlineVector.cpp
===================================================================
--- src/tests/InlineVector.cpp (revision 788779)
+++ src/tests/InlineVector.cpp (working copy)
@@ -30,6 +30,10 @@
typedef InlineVector<int, 3> Vec;
bool isInline(const Vec& v) {
+ // If nothing, give it the benefit of the doubt;
+ // can't take address of nothing.
+ if (v.size() <= 0)
+ return true;
return (const char*)&v <= (const char*)(&v[0]) &&
(const char*)(&v[0]) < (const char*)&v+sizeof(v);
}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project: http://qpid.apache.org
Use/Interact: mailto:[email protected]