mirror of
https://github.com/mdbtools/mdbtools.git
synced 2025-04-05 20:31:00 +08:00
Try another SQLGetData fix
Set the length of the return value to include the NUL termination charaacter.
This commit is contained in:
parent
e330feebd6
commit
71e10395fd
@ -1641,21 +1641,22 @@ SQLRETURN SQL_API SQLGetData(
|
||||
return SQL_ERROR;
|
||||
}
|
||||
if (pcbValue) {
|
||||
*pcbValue = len - stmt->pos;
|
||||
*pcbValue = len + 1 - stmt->pos;
|
||||
}
|
||||
if (cbValueMax == 0) {
|
||||
free(str);
|
||||
str = NULL;
|
||||
return SQL_SUCCESS_WITH_INFO;
|
||||
}
|
||||
snprintf(rgbValue, cbValueMax, "%s", str + stmt->pos);
|
||||
if (stmt->pos + cbValueMax < len + 1) {
|
||||
stmt->pos += cbValueMax - 1;
|
||||
|
||||
memcpy(rgbValue, str + stmt->pos, MIN(len - stmt->pos, cbValueMax-1));
|
||||
((char *)rgbValue)[MIN(len - stmt->pos, cbValueMax-1)] = '\0';
|
||||
stmt->pos += MIN(len - stmt->pos, cbValueMax-1);
|
||||
if (cbValueMax - 1 < len - stmt->pos) {
|
||||
if (col->col_type != MDB_OLE) { free(str); str = NULL; }
|
||||
strcpy(sqlState, "01004"); // truncated
|
||||
return SQL_SUCCESS_WITH_INFO;
|
||||
}
|
||||
stmt->pos = len;
|
||||
free(str);
|
||||
str = NULL;
|
||||
break;
|
||||
|
Loading…
Reference in New Issue
Block a user