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 {
|
arangodb::aql::QueryResult& queryResult) const {
|
||||||
// build "extra" attribute
|
// build "extra" attribute
|
||||||
arangodb::basics::Json extra(arangodb::basics::Json::Object);
|
arangodb::basics::Json extra(arangodb::basics::Json::Object);
|
||||||
VPackSlice stats = queryResult.stats->slice();
|
if (queryResult.stats != nullptr) {
|
||||||
|
VPackSlice stats = queryResult.stats->slice();
|
||||||
if (!stats.isNone()) {
|
if (!stats.isNone()) {
|
||||||
extra.set("stats",
|
extra.set("stats",
|
||||||
arangodb::basics::Json(
|
arangodb::basics::Json(
|
||||||
TRI_UNKNOWN_MEM_ZONE,
|
TRI_UNKNOWN_MEM_ZONE,
|
||||||
arangodb::basics::VelocyPackHelper::velocyPackToJson(stats),
|
arangodb::basics::VelocyPackHelper::velocyPackToJson(stats),
|
||||||
arangodb::basics::Json::AUTOFREE));
|
arangodb::basics::Json::AUTOFREE));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (queryResult.profile != nullptr) {
|
if (queryResult.profile != nullptr) {
|
||||||
extra.set("profile",
|
extra.set("profile",
|
||||||
|
|
|
@ -234,18 +234,20 @@ void RestSimpleHandler::removeByKeys(VPackSlice const& slice) {
|
||||||
|
|
||||||
size_t ignored = 0;
|
size_t ignored = 0;
|
||||||
size_t removed = 0;
|
size_t removed = 0;
|
||||||
VPackSlice stats = queryResult.stats->slice();
|
if (queryResult.stats != nullptr) {
|
||||||
|
VPackSlice stats = queryResult.stats->slice();
|
||||||
|
|
||||||
if (!stats.isNone()) {
|
if (!stats.isNone()) {
|
||||||
TRI_ASSERT(stats.isObject());
|
TRI_ASSERT(stats.isObject());
|
||||||
VPackSlice found = stats.get("writesIgnored");
|
VPackSlice found = stats.get("writesIgnored");
|
||||||
if (found.isNumber()) {
|
if (found.isNumber()) {
|
||||||
ignored = found.getNumericValue<size_t>();
|
ignored = found.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
found = stats.get("writesExecuted");
|
found = stats.get("writesExecuted");
|
||||||
if (found.isNumber()) {
|
if (found.isNumber()) {
|
||||||
removed = found.getNumericValue<size_t>();
|
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 ignored = 0;
|
||||||
size_t removed = 0;
|
size_t removed = 0;
|
||||||
|
|
||||||
VPackSlice stats = queryResult.stats->slice();
|
if (queryResult.stats != nullptr) {
|
||||||
|
VPackSlice stats = queryResult.stats->slice();
|
||||||
|
|
||||||
if (!stats.isNone()) {
|
if (!stats.isNone()) {
|
||||||
TRI_ASSERT(stats.isObject());
|
TRI_ASSERT(stats.isObject());
|
||||||
VPackSlice found = stats.get("writesIgnored");
|
VPackSlice found = stats.get("writesIgnored");
|
||||||
if (found.isNumber()) {
|
if (found.isNumber()) {
|
||||||
ignored = found.getNumericValue<size_t>();
|
ignored = found.getNumericValue<size_t>();
|
||||||
}
|
}
|
||||||
|
|
||||||
found = stats.get("writesExecuted");
|
found = stats.get("writesExecuted");
|
||||||
if (found.isNumber()) {
|
if (found.isNumber()) {
|
||||||
removed = found.getNumericValue<size_t>();
|
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"),
|
result->Set(TRI_V8_ASCII_STRING("warnings"),
|
||||||
TRI_ObjectJson(isolate, queryResult.warnings));
|
TRI_ObjectJson(isolate, queryResult.warnings));
|
||||||
}
|
}
|
||||||
VPackSlice stats = queryResult.stats->slice();
|
if (queryResult.stats != nullptr) {
|
||||||
if (stats.isNone()) {
|
VPackSlice stats = queryResult.stats->slice();
|
||||||
result->Set(TRI_V8_STRING("stats"), v8::Object::New(isolate));
|
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 {
|
} 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"),
|
result->ForceSet(TRI_V8_ASCII_STRING("json"),
|
||||||
TRI_ObjectJson(isolate, queryResult.json));
|
TRI_ObjectJson(isolate, queryResult.json));
|
||||||
}
|
}
|
||||||
VPackSlice stats = queryResult.stats->slice();
|
if (queryResult.stats != nullptr) {
|
||||||
if (!stats.isNone()) {
|
VPackSlice stats = queryResult.stats->slice();
|
||||||
result->ForceSet(TRI_V8_ASCII_STRING("stats"),
|
if (!stats.isNone()) {
|
||||||
TRI_VPackToV8(isolate, stats));
|
result->ForceSet(TRI_V8_ASCII_STRING("stats"),
|
||||||
|
TRI_VPackToV8(isolate, stats));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (queryResult.profile != nullptr) {
|
if (queryResult.profile != nullptr) {
|
||||||
result->ForceSet(TRI_V8_ASCII_STRING("profile"),
|
result->ForceSet(TRI_V8_ASCII_STRING("profile"),
|
||||||
|
|
Loading…
Reference in New Issue