Skip to content

Commit 557db1e

Browse files
committed
Fixed cursor leak when statement execution fails
1 parent d9e9590 commit 557db1e

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22

33
## node-oracledb v1.4.0 (DD Mon YYYY)
44

5+
- Fixed cursor leak when statements execution fails.
6+
57
## node-oracledb v1.3.0 (15 Oct 2015)
68

79
- Added a `oracledb.oracleClientVersion` property giving the version of the Oracle

src/njs/src/njsConnection.cpp

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -945,7 +945,7 @@ void Connection::Async_Execute (uv_work_t *req)
945945
{
946946
executeBaton->error = NJSMessages::getErrorMsg (
947947
errBufferReturningInvalid );
948-
return;
948+
goto exitAsyncExecute;
949949

950950
}
951951
}
@@ -1005,7 +1005,7 @@ void Connection::Async_Execute (uv_work_t *req)
10051005
{
10061006
executeBaton->error = NJSMessages::getErrorMsg (
10071007
errSQLSyntaxError );
1008-
return;
1008+
goto exitAsyncExecute;
10091009
}
10101010
}
10111011
}
@@ -1090,10 +1090,7 @@ void Connection::Async_Execute (uv_work_t *req)
10901090
// process any lob descriptor out binds
10911091
Connection::Descr2protoILob ( executeBaton, 0, 0);
10921092
}
1093-
if ( executeBaton->dpistmt )
1094-
{
1095-
executeBaton->dpistmt->release ();
1096-
}
1093+
//dpistmt will be released in exitAsyncExecute label in case of non-RS
10971094
}
10981095
catch (dpi::Exception& e)
10991096
{
@@ -1113,6 +1110,16 @@ void Connection::Async_Execute (uv_work_t *req)
11131110
}
11141111
}
11151112
exitAsyncExecute:
1113+
/* Release the statement handle in case of errors or non-ResultSet
1114+
* In case of ResultSet and no errors, statement handle will be released
1115+
* while closing it.
1116+
*/
1117+
if ( ( ( !(executeBaton->error).empty() ) ||
1118+
( !executeBaton->getRS ) ) &&
1119+
executeBaton->dpistmt )
1120+
{
1121+
executeBaton->dpistmt->release ();
1122+
}
11161123
;
11171124
}
11181125

0 commit comments

Comments
 (0)