Skip to content

Commit 14a74cf

Browse files
committed
Fixed potential crash if connection.execute was used
1 parent e28f833 commit 14a74cf

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"author": "SQL ANYWHERE ",
33
"name": "sqlanywhere",
44
"description": "SQL Anywhere JavaScript Driver.",
5-
"version": "1.0.10",
5+
"version": "1.0.11",
66
"repository": {
77
"url": "https://github.com/sqlanywhere/node-sqlanywhere"
88
},

src/sqlanywhere.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -186,9 +186,7 @@ void executeAfter( uv_work_t *req )
186186
scoped_lock lock( baton->obj->conn_mutex );
187187

188188
if( baton->sqlany_stmt != NULL && baton->prepared_stmt ) {
189-
if( api.initialized ) {
190-
api.sqlany_free_stmt( baton->sqlany_stmt );
191-
}
189+
// the StmtObject will free sqlany_stmt
192190
baton->sqlany_stmt = NULL;
193191
}
194192

@@ -373,6 +371,7 @@ NODE_API_FUNC( Connection::exec )
373371

374372
if( baton->sqlany_stmt != NULL ) {
375373
api.sqlany_free_stmt( baton->sqlany_stmt );
374+
baton->sqlany_stmt = NULL;
376375
}
377376

378377
delete baton;
@@ -774,8 +773,6 @@ void Connection::disconnectWork( uv_work_t *req )
774773
}
775774
// Must free the connection object or there will be a memory leak
776775
api.sqlany_free_connection( baton->obj->conn );
777-
778-
779776
baton->obj->conn = NULL;
780777
openConnections--;
781778

0 commit comments

Comments
 (0)