Skip to content

Commit c384eb1

Browse files
committed
Fixed regression with empty parameter list
If conn.exec or stmt.exec was called with an explicitly empty parameter list (i.e. passing [] rather than not passing parameters at all), the driver would crash. This has been fixed. Change-Id: I6181954e41f3cc4eaa32f782c6e0d16c3f11f6f4
1 parent 1a424ad commit c384eb1

File tree

3 files changed

+21
-1
lines changed

3 files changed

+21
-1
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.16",
5+
"version": "1.0.17",
66
"repository": {
77
"url": "https://github.com/sqlanywhere/node-sqlanywhere"
88
},

src/utils.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,13 @@ static bool getWideBindParameters( std::vector<ExecuteData *> &execData,
195195
unsigned num_cols = row0->Length();
196196
unsigned c;
197197

198+
if( num_cols == 0 ) {
199+
// if an empty array was passed in, we still need ExecuteData
200+
ExecuteData *ex = new ExecuteData;
201+
execData.push_back( ex );
202+
return true;
203+
}
204+
198205
// Make sure that each array in the list has the same number and types
199206
// of values
200207
for( unsigned int r = 1; r < num_rows; r++ ) {
@@ -298,6 +305,9 @@ bool getBindParameters( std::vector<ExecuteData *> &execData,
298305
Handle<Array> bind_params = Handle<Array>::Cast( arg );
299306

300307
if( bind_params->Length() == 0 ) {
308+
// if an empty array was passed in, we still need ExecuteData
309+
ExecuteData *ex = new ExecuteData;
310+
execData.push_back( ex );
301311
return true;
302312
}
303313

src/utils_v0_10.cpp

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,13 @@ static bool getWideBindParameters( std::vector<ExecuteData *> &execData,
162162
Handle<Array> row0 = Handle<Array>::Cast( rows->Get(0) );
163163
unsigned num_cols = row0->Length();
164164
unsigned c;
165+
166+
if( num_cols == 0 ) {
167+
// if an empty array was passed in, we still need ExecuteData
168+
ExecuteData *ex = new ExecuteData;
169+
execData.push_back( ex );
170+
return true;
171+
}
165172

166173
// Make sure that each array in the list has the same number and types
167174
// of values
@@ -267,6 +274,9 @@ bool getBindParameters( std::vector<ExecuteData *> &execData
267274
Handle<Array> bind_params = Handle<Array>::Cast( arg );
268275

269276
if( bind_params->Length() == 0 ) {
277+
// if an empty array was passed in, we still need ExecuteData
278+
ExecuteData *ex = new ExecuteData;
279+
execData.push_back( ex );
270280
return true;
271281
}
272282

0 commit comments

Comments
 (0)