diff --git a/arangod/Cluster/ServerJob.cpp b/arangod/Cluster/ServerJob.cpp index 0ee68f91e3..ab12f8e58b 100644 --- a/arangod/Cluster/ServerJob.cpp +++ b/arangod/Cluster/ServerJob.cpp @@ -136,14 +136,18 @@ ServerJobResult ServerJob::execute() { } if (!handlePlanChange->IsFunction()) { - LOG(ERR) << "handlePlanChange is not a funtion"; + LOG(ERR) << "handlePlanChange is not a function"; return result; } v8::Handle func = v8::Handle::Cast(handlePlanChange); v8::Handle args[2]; - args[0] = TRI_VPackToV8(isolate, clusterInfo->getPlan()->slice()); - args[1] = TRI_VPackToV8(isolate, clusterInfo->getCurrent()->slice()); + // Keep the shared_ptr to the builder while we run TRI_VPackToV8 on the + // slice(), just to be on the safe side: + auto builder = clusterInfo->getPlan(); + args[0] = TRI_VPackToV8(isolate, builder->slice()); + builder = clusterInfo->getCurrent(); + args[1] = TRI_VPackToV8(isolate, builder->slice()); v8::Handle res = func->Call(isolate->GetCurrentContext()->Global(), 2, args);