From 1dea6b29a512171450eb2558a23552e68e832ff7 Mon Sep 17 00:00:00 2001 From: Willi Goesgens Date: Tue, 30 Jun 2015 14:36:37 +0200 Subject: [PATCH] Fix memleaks in coordinator. --- arangod/Cluster/ClusterInfo.cpp | 2 +- arangod/RestHandler/RestReplicationHandler.cpp | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/arangod/Cluster/ClusterInfo.cpp b/arangod/Cluster/ClusterInfo.cpp index c774dc131c..c8f42cece4 100644 --- a/arangod/Cluster/ClusterInfo.cpp +++ b/arangod/Cluster/ClusterInfo.cpp @@ -1452,7 +1452,7 @@ int ClusterInfo::ensureIndexCoordinator (string const& databaseName, const double endTime = TRI_microtime() + realTimeout; const double interval = getPollInterval(); - resultJson = 0; + resultJson = nullptr; TRI_json_t* newIndex = nullptr; int numberOfShards = 0; diff --git a/arangod/RestHandler/RestReplicationHandler.cpp b/arangod/RestHandler/RestReplicationHandler.cpp index e0f7501785..635bd0e1f9 100644 --- a/arangod/RestHandler/RestReplicationHandler.cpp +++ b/arangod/RestHandler/RestReplicationHandler.cpp @@ -652,7 +652,8 @@ void RestReplicationHandler::handleCommandBatch () { TRI_json_t json; TRI_InitObjectJson(TRI_CORE_MEM_ZONE, &json); char* idString = TRI_StringUInt64((uint64_t) id); - TRI_Insert3ObjectJson(TRI_CORE_MEM_ZONE, &json, "id", TRI_CreateStringJson(TRI_CORE_MEM_ZONE, idString, strlen(idString))); + TRI_Insert3ObjectJson(TRI_CORE_MEM_ZONE, &json, "id", + TRI_CreateStringJson(TRI_CORE_MEM_ZONE, idString, strlen(idString))); generateResult(&json); TRI_DestroyJson(TRI_CORE_MEM_ZONE, &json); @@ -1832,8 +1833,8 @@ int RestReplicationHandler::processRestoreCollectionCoordinator ( TRI_voc_tick_t new_id_tick = ci->uniqid(1); string new_id = StringUtils::itoa(new_id_tick); TRI_ReplaceObjectJson(TRI_UNKNOWN_MEM_ZONE, parameters, "id", - TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, - new_id.c_str(), new_id.size())); + TRI_CreateStringCopyJson(TRI_UNKNOWN_MEM_ZONE, + new_id.c_str(), new_id.size())); // Now put in the primary and an edge index if needed: TRI_json_t* indexes = TRI_CreateArrayJson(TRI_UNKNOWN_MEM_ZONE); @@ -2054,6 +2055,9 @@ int RestReplicationHandler::processRestoreIndexesCoordinator ( TRI_json_t* res_json = nullptr; res = ci->ensureIndexCoordinator(dbName, col->id_as_string(), idxDef, true, triagens::arango::Index::Compare, res_json, errorMsg, 3600.0); + if (res_json != nullptr) { + TRI_FreeJson(TRI_UNKNOWN_MEM_ZONE, res_json); + } if (res != TRI_ERROR_NO_ERROR) { errorMsg = "could not create index: " + string(TRI_errno_string(res)); break;