From a222d13a5604c98d8fae23e310d65cb9cef60ac5 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Mon, 16 May 2016 22:40:06 +0200 Subject: [PATCH] fixed undefined behavior --- arangod/Aql/AstNode.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/arangod/Aql/AstNode.cpp b/arangod/Aql/AstNode.cpp index 136c58d4f9..c854120dd6 100644 --- a/arangod/Aql/AstNode.cpp +++ b/arangod/Aql/AstNode.cpp @@ -320,15 +320,15 @@ int arangodb::aql::CompareAstNodes(AstNode const* lhs, AstNode const* rhs, } if (lType == TRI_JSON_STRING) { - size_t maxLength = - (std::max)(lhs->getStringLength(), rhs->getStringLength()); - if (compareUtf8) { return TRI_compare_utf8(lhs->getStringValue(), lhs->getStringLength(), rhs->getStringValue(), rhs->getStringLength()); } + + size_t const minLength = + (std::min)(lhs->getStringLength(), rhs->getStringLength()); - int res = memcmp(lhs->getStringValue(), rhs->getStringValue(), maxLength); + int res = memcmp(lhs->getStringValue(), rhs->getStringValue(), minLength); if (res != 0) { return res;