mirror of https://gitee.com/bigwinds/arangodb
fix some undefined behavior
This commit is contained in:
parent
3918c66399
commit
2d795c1f8a
|
@ -810,6 +810,7 @@ uint8_t* Builder::set(ValuePair const& pair) {
|
|||
uint64_t v = pair.getSize();
|
||||
reserve(9 + v);
|
||||
appendUInt(v, 0xbf);
|
||||
VELOCYPACK_ASSERT(pair.getStart() != nullptr);
|
||||
memcpy(_start + _pos, pair.getStart(), checkOverflow(v));
|
||||
advance(v);
|
||||
return _start + oldPos;
|
||||
|
@ -825,6 +826,7 @@ uint8_t* Builder::set(ValuePair const& pair) {
|
|||
reserve(1 + size);
|
||||
appendByteUnchecked(static_cast<uint8_t>(0x40 + size));
|
||||
}
|
||||
VELOCYPACK_ASSERT(pair.getStart() != nullptr);
|
||||
memcpy(_start + _pos, pair.getStart(), checkOverflow(size));
|
||||
advance(size);
|
||||
return _start + oldPos;
|
||||
|
|
|
@ -710,9 +710,9 @@ AstNode* Ast::createNodeAccess(Variable const* variable,
|
|||
return node;
|
||||
}
|
||||
|
||||
AstNode* Ast::createNodeAttributeAccess(AstNode const* refNode, std::vector<std::string> const& path){
|
||||
AstNode* Ast::createNodeAttributeAccess(AstNode const* refNode, std::vector<std::string> const& path) {
|
||||
AstNode* rv = refNode->clone(this);
|
||||
for(auto const& part : path){
|
||||
for (auto const& part : path) {
|
||||
char const* p = query()->registerString(part.data(), part.size());
|
||||
rv = createNodeAttributeAccess(rv, p, part.size());
|
||||
}
|
||||
|
@ -720,10 +720,7 @@ AstNode* Ast::createNodeAttributeAccess(AstNode const* refNode, std::vector<std:
|
|||
}
|
||||
|
||||
/// @brief create an AST parameter node
|
||||
AstNode* Ast::createNodeParameter(
|
||||
char const* name,
|
||||
size_t length
|
||||
) {
|
||||
AstNode* Ast::createNodeParameter(char const* name, size_t length) {
|
||||
if (name == nullptr) {
|
||||
THROW_ARANGO_EXCEPTION(TRI_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
|
@ -739,23 +736,23 @@ AstNode* Ast::createNodeParameter(
|
|||
}
|
||||
|
||||
AstNode* Ast::createNodeParameterCollection(char const* name, size_t length) {
|
||||
auto node = createNodeParameter(name, length);
|
||||
// prevent creating a collection node with a nullptr string
|
||||
auto collection = createNode(NODE_TYPE_COLLECTION);
|
||||
collection->setStringValue("", 0);
|
||||
|
||||
if (node) {
|
||||
node->reserve(1);
|
||||
node->addMember(createNode(NODE_TYPE_COLLECTION));
|
||||
}
|
||||
auto node = createNodeParameter(name, length);
|
||||
node->addMember(collection);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
||||
AstNode* Ast::createNodeParameterView(char const* name, size_t length) {
|
||||
auto node = createNodeParameter(name, length);
|
||||
// prevent creating a view node with a nullptr string
|
||||
auto view = createNode(NODE_TYPE_VIEW);
|
||||
view->setStringValue("", 0);
|
||||
|
||||
if (node) {
|
||||
node->reserve(1);
|
||||
node->addMember(createNode(NODE_TYPE_VIEW));
|
||||
}
|
||||
auto node = createNodeParameter(name, length);
|
||||
node->addMember(view);
|
||||
|
||||
return node;
|
||||
}
|
||||
|
|
|
@ -1078,6 +1078,7 @@ void AstNode::toVelocyPack(VPackBuilder& builder, bool verbose) const {
|
|||
type == NODE_TYPE_ATTRIBUTE_ACCESS || type == NODE_TYPE_VIEW ||
|
||||
type == NODE_TYPE_OBJECT_ELEMENT || type == NODE_TYPE_FCALL_USER) {
|
||||
// dump "name" of node
|
||||
TRI_ASSERT(getStringValue() != nullptr);
|
||||
builder.add("name", VPackValuePair(getStringValue(), getStringLength(),
|
||||
VPackValueType::String));
|
||||
}
|
||||
|
|
|
@ -123,9 +123,13 @@ std::string getFirstKey(std::vector<AstNode const*> const& compares) {
|
|||
}
|
||||
|
||||
bool depIsSingletonOrConstCalc(ExecutionNode const* node) {
|
||||
while (node){
|
||||
while (node) {
|
||||
node = node->getFirstDependency();
|
||||
if(node->getType() == EN::SINGLETON) {
|
||||
if (node == nullptr) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (node->getType() == EN::SINGLETON) {
|
||||
return true;
|
||||
}
|
||||
|
||||
|
|
|
@ -58,7 +58,7 @@ function queryWithCollectionsTestSuite () {
|
|||
////////////////////////////////////////////////////////////////////////////////
|
||||
/// @brief test with at invalid position
|
||||
////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
testWithInvalidPos1 : function () {
|
||||
assertQueryError(errors.ERROR_QUERY_PARSE.code, "LET a = 1 WITH UnitTestsCollection1 RETURN 1");
|
||||
},
|
||||
|
@ -330,7 +330,6 @@ function queryWithCollectionsTestSuite () {
|
|||
var collections = AQL_PARSE(query).collections;
|
||||
assertEqual([ "_users" ], collections);
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -341,8 +340,3 @@ function queryWithCollectionsTestSuite () {
|
|||
jsunity.run(queryWithCollectionsTestSuite);
|
||||
|
||||
return jsunity.done();
|
||||
|
||||
// Local Variables:
|
||||
// mode: outline-minor
|
||||
// outline-regexp: "^\\(/// @brief\\|/// @addtogroup\\|// --SECTION--\\|/// @page\\|/// @}\\)"
|
||||
// End:
|
||||
|
|
Loading…
Reference in New Issue