Skip to content

Commit f83c2f6

Browse files
committed
sqlite: fix sqlite3_stmt leak in prepare create failure
1 parent 38647b3 commit f83c2f6

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/node_sqlite.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,6 +1511,10 @@ void DatabaseSync::Prepare(const FunctionCallbackInfo<Value>& args) {
15111511
CHECK_ERROR_OR_THROW(env->isolate(), db, r, SQLITE_OK, void());
15121512
BaseObjectPtr<StatementSync> stmt =
15131513
StatementSync::Create(env, BaseObjectPtr<DatabaseSync>(db), s);
1514+
if (!stmt) {
1515+
sqlite3_finalize(s);
1516+
return;
1517+
}
15141518
db->statements_.insert(stmt.get());
15151519

15161520
if (return_arrays.has_value()) {

0 commit comments

Comments
 (0)