Skip to content

Commit

Permalink
Allocate canFreeHandle on the heap before instantiating instances of …
Browse files Browse the repository at this point in the history
…ODBCResult
  • Loading branch information
wankdanker committed Apr 30, 2013
1 parent a1f69d1 commit ac63fb2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
10 changes: 5 additions & 5 deletions src/odbc_connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -806,12 +806,12 @@ void ODBCConnection::UV_AfterQuery(uv_work_t* req, int status) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down Expand Up @@ -1047,12 +1047,12 @@ Handle<Value> ODBCConnection::QuerySync(const Arguments& args) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down Expand Up @@ -1331,4 +1331,4 @@ Handle<Value> ODBCConnection::EndTransactionSync(const Arguments& args) {
else {
return scope.Close(True());
}
}
}
3 changes: 3 additions & 0 deletions src/odbc_result.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ Handle<Value> 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;

Expand Down
16 changes: 8 additions & 8 deletions src/odbc_statement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,12 +184,12 @@ void ODBCStatement::UV_AfterExecute(uv_work_t* req, int status) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down Expand Up @@ -282,12 +282,12 @@ Handle<Value> ODBCStatement::ExecuteSync(const Arguments& args) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down Expand Up @@ -544,12 +544,12 @@ void ODBCStatement::UV_AfterExecuteDirect(uv_work_t* req, int status) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down Expand Up @@ -608,12 +608,12 @@ Handle<Value> ODBCStatement::ExecuteDirectSync(const Arguments& args) {
}
else {
Local<Value> 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<Object> js_result(ODBCResult::constructor_template->
GetFunction()->NewInstance(4, args));
Expand Down

0 comments on commit ac63fb2

Please sign in to comment.