Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 12 additions & 4 deletions src/odbc_cursor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,9 +84,13 @@ class FetchAsyncWorker : public ODBCAsyncWorker {

public:
FetchAsyncWorker(ODBCCursor* cursor, Napi::Function& callback)
: ODBCAsyncWorker(callback), cursor(cursor), data(cursor->data) {}
: ODBCAsyncWorker(callback), cursor(cursor), data(cursor->data) {
// Keep the JS-side cursor object alive (preventing GC from running its
// destructor, which frees data->hstmt) while this worker is in flight.
this->cursor->Ref();
}

~FetchAsyncWorker() {}
~FetchAsyncWorker() { this->cursor->Unref(); }

void Execute() {
SQLRETURN return_code;
Expand Down Expand Up @@ -155,9 +159,13 @@ class CursorCloseAsyncWorker : public ODBCAsyncWorker {

public:
CursorCloseAsyncWorker(ODBCCursor* cursor, Napi::Function& callback)
: ODBCAsyncWorker(callback), odbcCursor(cursor), data(cursor->data) {}
: ODBCAsyncWorker(callback), odbcCursor(cursor), data(cursor->data) {
// Keep the JS-side cursor object alive (preventing GC from running its
// destructor, which frees data->hstmt) while this worker is in flight.
this->odbcCursor->Ref();
}

~CursorCloseAsyncWorker() {}
~CursorCloseAsyncWorker() { this->odbcCursor->Unref(); }

void Execute() {

Expand Down
Loading