From b1395ce1bdab543b1d19ebd167f17f594f39f6d8 Mon Sep 17 00:00:00 2001 From: Max Neunhoeffer Date: Fri, 24 Jun 2016 16:37:49 +0200 Subject: [PATCH 1/2] No longer use return value of next() method of ArrayIterator. --- arangod/Aql/Functions.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/arangod/Aql/Functions.cpp b/arangod/Aql/Functions.cpp index 637e665f10..a72fce5c03 100644 --- a/arangod/Aql/Functions.cpp +++ b/arangod/Aql/Functions.cpp @@ -3186,8 +3186,10 @@ AqlValue Functions::Shift(arangodb::aql::Query* query, auto iterator = VPackArrayIterator(l); // This jumps over the first element - while (iterator.next()) { + iterator.next(); + while (iterator.valid()) { builder->add(iterator.value()); + iterator.next(); } } builder->close(); From b126df61c29a514a606c336ec7b7e87a75c96f32 Mon Sep 17 00:00:00 2001 From: Wilfried Goesgens Date: Fri, 24 Jun 2016 17:18:10 +0200 Subject: [PATCH 2/2] Improve error handling for invalid graph definitions --- arangod/Aql/Graphs.cpp | 24 ++++++++++++++++++------ 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/arangod/Aql/Graphs.cpp b/arangod/Aql/Graphs.cpp index 6881d353f5..d8cd364ba8 100644 --- a/arangod/Aql/Graphs.cpp +++ b/arangod/Aql/Graphs.cpp @@ -108,14 +108,26 @@ Graph::Graph(VPackSlice const& info) : _vertexColls(), _edgeColls() { for (auto const& def : VPackArrayIterator(edgeDefs)) { TRI_ASSERT(def.isObject()); - std::string eCol = arangodb::basics::VelocyPackHelper::getStringValue( + try { + std::string eCol = arangodb::basics::VelocyPackHelper::getStringValue( def, "collection", ""); - addEdgeCollection(eCol); + addEdgeCollection(eCol); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find 'collection' in the graph definition"); + } // TODO what if graph is not in a valid format any more - VPackSlice tmp = def.get("from"); - insertVertexCollections(tmp); - tmp = def.get("to"); - insertVertexCollections(tmp); + try { + VPackSlice tmp = def.get("from"); + insertVertexCollections(tmp); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find from-collection in the graph definition"); + } + try { + VPackSlice tmp = def.get("to"); + insertVertexCollections(tmp); + } catch (...) { + THROW_ARANGO_EXCEPTION_MESSAGE(TRI_ERROR_GRAPH_INVALID_GRAPH, "didn't find to-collection in the graph definition"); + } } } if (slice.hasKey(_attrOrphans)) {