Skip to content

Commit

Permalink
chore: ensure keys and values have same size
Browse files Browse the repository at this point in the history
  • Loading branch information
tpoisseau committed Aug 28, 2024
1 parent d0c8655 commit 41cdbd7
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/node_sqlite.cc
Original file line number Diff line number Diff line change
Expand Up @@ -528,8 +528,9 @@ void StatementSync::IterateReturnCallback(
LocalVector<Value> values(isolate,
{Boolean::New(isolate, true), Null(isolate)});

Local<Object> result =
Object::New(isolate, Null(isolate), keys.data(), values.data(), 2);
DCHECK_EQ(keys.size(), values.size());
Local<Object> result = Object::New(
isolate, Null(isolate), keys.data(), values.data(), keys.size());
args.GetReturnValue().Set(result);
}

Expand All @@ -554,8 +555,9 @@ void StatementSync::IterateNextCallback(
LocalVector<Value> values(isolate,
{Boolean::New(isolate, true), Null(isolate)});

Local<Object> result =
Object::New(isolate, Null(isolate), keys.data(), values.data(), 2);
DCHECK_EQ(keys.size(), values.size());
Local<Object> result = Object::New(
isolate, Null(isolate), keys.data(), values.data(), keys.size());
args.GetReturnValue().Set(result);
return;
}
Expand All @@ -579,8 +581,9 @@ void StatementSync::IterateNextCallback(
LocalVector<Name> keys(isolate, {env->done_string(), env->value_string()});
LocalVector<Value> values(isolate, {Boolean::New(isolate, false), row});

Local<Object> result =
Object::New(isolate, Null(isolate), keys.data(), values.data(), 2);
DCHECK_EQ(keys.size(), values.size());
Local<Object> result = Object::New(
isolate, Null(isolate), keys.data(), values.data(), keys.size());
args.GetReturnValue().Set(result);
}

Expand Down Expand Up @@ -629,8 +632,9 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
.ToLocalChecked()
.As<Object>();

DCHECK_EQ(keys.size(), values.size());
Local<Object> iterable_iterator = Object::New(
isolate, js_iterator_prototype, keys.data(), values.data(), 2);
isolate, js_iterator_prototype, keys.data(), values.data(), keys.size());
args.GetReturnValue().Set(iterable_iterator);
}

Expand Down

0 comments on commit 41cdbd7

Please sign in to comment.