sqlite: reject deserialize() while in a callback · nodejs/node@c89878c · GitHub
Skip to content

Commit c89878c

Browse files
trivikraduh95
authored andcommitted
sqlite: reject deserialize() while in a callback
deserialize() could be called from a user-defined function invoked during statement execution, tearing down the database connection while sqlite3_step() was still using it. Reuse the existing callback depth check to throw ERR_INVALID_STATE instead, matching the guard already in place for close(). Signed-off-by: Kamat, Trivikram <16024985+trivikr@users.noreply.github.com> Assisted-by: codex:gpt-5.6-sol PR-URL: #64796 Refs: #64795 Reviewed-By: Stephen Belanger <admin@stephenbelanger.com>
1 parent 3e6688c commit c89878c

3 files changed

Lines changed: 26 additions & 2 deletions

File tree

doc/api/sqlite.md

Lines changed: 5 additions & 2 deletions

src/node_sqlite.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1858,6 +1858,10 @@ void DatabaseSync::Deserialize(const FunctionCallbackInfo<Value>& args) {
18581858
ASSIGN_OR_RETURN_UNWRAP(&db, args.This());
18591859
Environment* env = Environment::GetCurrent(args);
18601860
THROW_AND_RETURN_ON_BAD_STATE(env, !db->IsOpen(), "database is not open");
1861+
THROW_AND_RETURN_ON_BAD_STATE(
1862+
env,
1863+
db->IsInCallback(),
1864+
"database cannot be deserialized while in a callback");
18611865

18621866
if (!args[0]->IsUint8Array()) {
18631867
THROW_ERR_INVALID_ARG_TYPE(env->isolate(),

test/parallel/test-sqlite-serialize.js

Lines changed: 17 additions & 0 deletions

0 commit comments

Comments
 (0)