From bd6d48760c9493a2c8820ababa5c621743d3bb82 Mon Sep 17 00:00:00 2001 From: jsteemann Date: Mon, 19 Dec 2016 21:41:29 +0100 Subject: [PATCH] fix memleak --- arangod/Indexes/GeoIndex.cpp | 4 ++-- arangod/Indexes/GeoIndex.h | 12 ++++++++++++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arangod/Indexes/GeoIndex.cpp b/arangod/Indexes/GeoIndex.cpp index 0d605f9a02..09ef14a8f0 100644 --- a/arangod/Indexes/GeoIndex.cpp +++ b/arangod/Indexes/GeoIndex.cpp @@ -106,13 +106,13 @@ void GeoIndexIterator::nextBabies(std::vector& result, size_t result.clear(); if (batchSize > 0) { auto coords = std::unique_ptr(::GeoIndex_ReadCursor(_cursor,batchSize)); + size_t length = coords ? coords->length : 0; //LOG_TOPIC(DEBUG, Logger::DEVEL) << "length " << length; - if (!length){ + if (!length) { return; } - for(std::size_t index = 0; index < length; ++index){ //LOG_TOPIC(DEBUG, Logger::DEVEL) << "near " << _near << " max allowed range: " << _withinRange // << " actual range: " << GeoIndex_distance(&_coor, &coords->coordinates[index]) ; diff --git a/arangod/Indexes/GeoIndex.h b/arangod/Indexes/GeoIndex.h index ca0195d7cd..0fdba7f795 100644 --- a/arangod/Indexes/GeoIndex.h +++ b/arangod/Indexes/GeoIndex.h @@ -180,4 +180,16 @@ friend class GeoIndexIterator; }; } +namespace std { +template <> +class default_delete { + public: + void operator()(GeoCoordinates* result) { + if (result != nullptr) { + GeoIndex_CoordinatesFree(result); + } + } +}; +} + #endif