mirror of https://gitee.com/bigwinds/arangodb
Fixed error where a nullptr was dereferenced without any checks
This commit is contained in:
parent
09c9bdcd23
commit
bc1b69af70
|
@ -325,14 +325,15 @@ arangodb::basics::Json RestCursorHandler::buildExtra(
|
|||
arangodb::aql::QueryResult& queryResult) const {
|
||||
// build "extra" attribute
|
||||
arangodb::basics::Json extra(arangodb::basics::Json::Object);
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
|
||||
if (!stats.isNone()) {
|
||||
extra.set("stats",
|
||||
arangodb::basics::Json(
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
arangodb::basics::VelocyPackHelper::velocyPackToJson(stats),
|
||||
arangodb::basics::Json::AUTOFREE));
|
||||
if (queryResult.stats != nullptr) {
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (!stats.isNone()) {
|
||||
extra.set("stats",
|
||||
arangodb::basics::Json(
|
||||
TRI_UNKNOWN_MEM_ZONE,
|
||||
arangodb::basics::VelocyPackHelper::velocyPackToJson(stats),
|
||||
arangodb::basics::Json::AUTOFREE));
|
||||
}
|
||||
}
|
||||
if (queryResult.profile != nullptr) {
|
||||
extra.set("profile",
|
||||
|
|
|
@ -234,18 +234,20 @@ void RestSimpleHandler::removeByKeys(VPackSlice const& slice) {
|
|||
|
||||
size_t ignored = 0;
|
||||
size_t removed = 0;
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (queryResult.stats != nullptr) {
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
|
||||
if (!stats.isNone()) {
|
||||
TRI_ASSERT(stats.isObject());
|
||||
VPackSlice found = stats.get("writesIgnored");
|
||||
if (found.isNumber()) {
|
||||
ignored = found.getNumericValue<size_t>();
|
||||
}
|
||||
if (!stats.isNone()) {
|
||||
TRI_ASSERT(stats.isObject());
|
||||
VPackSlice found = stats.get("writesIgnored");
|
||||
if (found.isNumber()) {
|
||||
ignored = found.getNumericValue<size_t>();
|
||||
}
|
||||
|
||||
found = stats.get("writesExecuted");
|
||||
if (found.isNumber()) {
|
||||
removed = found.getNumericValue<size_t>();
|
||||
found = stats.get("writesExecuted");
|
||||
if (found.isNumber()) {
|
||||
removed = found.getNumericValue<size_t>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -2149,18 +2149,20 @@ static void JS_RemoveByKeys(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
size_t ignored = 0;
|
||||
size_t removed = 0;
|
||||
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (queryResult.stats != nullptr) {
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
|
||||
if (!stats.isNone()) {
|
||||
TRI_ASSERT(stats.isObject());
|
||||
VPackSlice found = stats.get("writesIgnored");
|
||||
if (found.isNumber()) {
|
||||
ignored = found.getNumericValue<size_t>();
|
||||
}
|
||||
if (!stats.isNone()) {
|
||||
TRI_ASSERT(stats.isObject());
|
||||
VPackSlice found = stats.get("writesIgnored");
|
||||
if (found.isNumber()) {
|
||||
ignored = found.getNumericValue<size_t>();
|
||||
}
|
||||
|
||||
found = stats.get("writesExecuted");
|
||||
if (found.isNumber()) {
|
||||
removed = found.getNumericValue<size_t>();
|
||||
found = stats.get("writesExecuted");
|
||||
if (found.isNumber()) {
|
||||
removed = found.getNumericValue<size_t>();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1163,11 +1163,15 @@ static void JS_ExplainAql(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
result->Set(TRI_V8_ASCII_STRING("warnings"),
|
||||
TRI_ObjectJson(isolate, queryResult.warnings));
|
||||
}
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (stats.isNone()) {
|
||||
result->Set(TRI_V8_STRING("stats"), v8::Object::New(isolate));
|
||||
if (queryResult.stats != nullptr) {
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (stats.isNone()) {
|
||||
result->Set(TRI_V8_STRING("stats"), v8::Object::New(isolate));
|
||||
} else {
|
||||
result->Set(TRI_V8_STRING("stats"), TRI_VPackToV8(isolate, stats));
|
||||
}
|
||||
} else {
|
||||
result->Set(TRI_V8_STRING("stats"), TRI_VPackToV8(isolate, stats));
|
||||
result->Set(TRI_V8_STRING("stats"), v8::Object::New(isolate));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1229,10 +1233,12 @@ static void JS_ExecuteAqlJson(v8::FunctionCallbackInfo<v8::Value> const& args) {
|
|||
result->ForceSet(TRI_V8_ASCII_STRING("json"),
|
||||
TRI_ObjectJson(isolate, queryResult.json));
|
||||
}
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (!stats.isNone()) {
|
||||
result->ForceSet(TRI_V8_ASCII_STRING("stats"),
|
||||
TRI_VPackToV8(isolate, stats));
|
||||
if (queryResult.stats != nullptr) {
|
||||
VPackSlice stats = queryResult.stats->slice();
|
||||
if (!stats.isNone()) {
|
||||
result->ForceSet(TRI_V8_ASCII_STRING("stats"),
|
||||
TRI_VPackToV8(isolate, stats));
|
||||
}
|
||||
}
|
||||
if (queryResult.profile != nullptr) {
|
||||
result->ForceSet(TRI_V8_ASCII_STRING("profile"),
|
||||
|
|
Loading…
Reference in New Issue