Skip to content

Commit

Permalink
Fixing both an SQL_FLOAT issue (was not in the ProcessForNapi list) a…
Browse files Browse the repository at this point in the history
…nd an issue with boundRow data to row data containing garbage data due to no null terminator
  • Loading branch information
markdirish committed Jun 13, 2019
1 parent 64672dd commit e17247b
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/odbc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -361,13 +361,14 @@ SQLRETURN ODBC::BindColumns(QueryData *data) {
switch(column->DataType) {

case SQL_REAL:
case SQL_DECIMAL :
case SQL_NUMERIC :
case SQL_DECIMAL:
case SQL_NUMERIC:
maxColumnLength = (column->ColumnSize + 1) * sizeof(SQLCHAR);
targetType = SQL_C_CHAR;
break;

case SQL_DOUBLE :
case SQL_FLOAT:
case SQL_DOUBLE:
maxColumnLength = column->ColumnSize;
targetType = SQL_C_DOUBLE;
break;
Expand Down Expand Up @@ -433,7 +434,7 @@ SQLRETURN ODBC::FetchAll(QueryData *data) {

while(SQL_SUCCEEDED(returnCode = SQLFetch(data->hSTMT))) {

ColumnData *row = new ColumnData[data->columnCount];
ColumnData *row = new ColumnData[data->columnCount]();

// Iterate over each column, putting the data in the row object
for (int i = 0; i < data->columnCount; i++) {
Expand All @@ -442,7 +443,7 @@ SQLRETURN ODBC::FetchAll(QueryData *data) {
if (row[i].size == SQL_NULL_DATA) {
row[i].data = NULL;
} else {
row[i].data = new SQLCHAR[row[i].size];
row[i].data = new SQLCHAR[row[i].size + 1]();
memcpy(row[i].data, data->boundRow[i], row[i].size);
}
}
Expand Down

0 comments on commit e17247b

Please sign in to comment.