1
0
Fork 0

A paranoid change to avoid a use after free. Fixed a typo.

This commit is contained in:
Max Neunhoeffer 2016-05-11 14:48:12 +02:00
parent 411f05a1b3
commit 071c51abe4
1 changed files with 7 additions and 3 deletions

View File

@ -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<v8::Function> func = v8::Handle<v8::Function>::Cast(handlePlanChange);
v8::Handle<v8::Value> 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<v8::Value> res = func->Call(isolate->GetCurrentContext()->Global(), 2, args);