From ac63fb2180d6f569c7fc5a21c609f935451ceaf0 Mon Sep 17 00:00:00 2001 From: Dan VerWeire Date: Mon, 29 Apr 2013 20:11:44 -0400 Subject: [PATCH] Allocate canFreeHandle on the heap before instantiating instances of ODBCResult --- src/odbc_connection.cpp | 10 +++++----- src/odbc_result.cpp | 3 +++ src/odbc_statement.cpp | 16 ++++++++-------- 3 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/odbc_connection.cpp b/src/odbc_connection.cpp index 8bb95747..dfd4c55b 100644 --- a/src/odbc_connection.cpp +++ b/src/odbc_connection.cpp @@ -806,12 +806,12 @@ void ODBCConnection::UV_AfterQuery(uv_work_t* req, int status) { } else { Local args[4]; - bool canFreeHandle = true; + bool* canFreeHandle = new bool(true); args[0] = External::New(data->conn->m_hENV); args[1] = External::New(data->conn->m_hDBC); args[2] = External::New(data->hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Persistent js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); @@ -1047,12 +1047,12 @@ Handle ODBCConnection::QuerySync(const Arguments& args) { } else { Local args[4]; - bool canFreeHandle; + bool* canFreeHandle = new bool(true); args[0] = External::New(conn->m_hENV); args[1] = External::New(conn->m_hDBC); args[2] = External::New(hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Persistent js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); @@ -1331,4 +1331,4 @@ Handle ODBCConnection::EndTransactionSync(const Arguments& args) { else { return scope.Close(True()); } -} \ No newline at end of file +} diff --git a/src/odbc_result.cpp b/src/odbc_result.cpp index 9ca4189c..1db2d3f4 100644 --- a/src/odbc_result.cpp +++ b/src/odbc_result.cpp @@ -110,6 +110,9 @@ Handle ODBCResult::New(const Arguments& args) { objODBCResult->m_canFreeHandle ); + //free the pointer to canFreeHandle + delete canFreeHandle; + //specify the buffer length objODBCResult->bufferLength = MAX_VALUE_SIZE - 1; diff --git a/src/odbc_statement.cpp b/src/odbc_statement.cpp index 9a8abc1e..98bef71e 100644 --- a/src/odbc_statement.cpp +++ b/src/odbc_statement.cpp @@ -184,12 +184,12 @@ void ODBCStatement::UV_AfterExecute(uv_work_t* req, int status) { } else { Local args[3]; - bool canFreeHandle = false; + bool* canFreeHandle = new bool(false); args[0] = External::New(self->m_hENV); args[1] = External::New(self->m_hDBC); args[2] = External::New(self->m_hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Persistent js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); @@ -282,12 +282,12 @@ Handle ODBCStatement::ExecuteSync(const Arguments& args) { } else { Local args[3]; - bool canFreeHandle = false; + bool* canFreeHandle = new bool(false); args[0] = External::New(stmt->m_hENV); args[1] = External::New(stmt->m_hDBC); args[2] = External::New(stmt->m_hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Local js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); @@ -544,12 +544,12 @@ void ODBCStatement::UV_AfterExecuteDirect(uv_work_t* req, int status) { } else { Local args[3]; - bool canFreeHandle = false; + bool* canFreeHandle = new bool(false); args[0] = External::New(self->m_hENV); args[1] = External::New(self->m_hDBC); args[2] = External::New(self->m_hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Persistent js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args)); @@ -608,12 +608,12 @@ Handle ODBCStatement::ExecuteDirectSync(const Arguments& args) { } else { Local args[3]; - bool canFreeHandle = false; + bool* canFreeHandle = new bool(false); args[0] = External::New(stmt->m_hENV); args[1] = External::New(stmt->m_hDBC); args[2] = External::New(stmt->m_hSTMT); - args[3] = External::New(&canFreeHandle); + args[3] = External::New(canFreeHandle); Persistent js_result(ODBCResult::constructor_template-> GetFunction()->NewInstance(4, args));