microsoft / microsoft/Windows-classic-samples
[Win7Sample.OleDb.RowsetViewer] Writing LONG data in SHORT variable
Nobody has claimed this yet.
- Dominant language
- No language data
- Stars
- 5.7k
- Forks
- 3.3k
- PR merge metrics
- No merged PRs in 30d
Description
VS Debugger found a problem with the following code:
DBTYPE is based on USHORT datatype.
I have not got any problems with this code within 20 years but I think it needs to correct it with:
LONG lSchemaType; /*DBTYPE == UI2*/
if(ConvertToLONG(pwszValue, &lSchemaType, 0/*Min*/, USHRT_MAX, 0/*Base*/))
{
//NOTE: on failure we have no choice to leave the column as the original
//returned integer.
StringCopy(pwszValue, GetDBTypeName((DBTYPE)lSchemaType), ulMaxSize);
}
I tested this new code under debugger - it works fine.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at Samples/Win7Samples/dataaccess/oledb/rowsetviewer/crowset.cpp lines 671-672, where the issue reports DBTYPE conversion. Review the surrounding conversion and string-copy logic, then build or run the RowsetViewer sample under the debugger. Done means the reported type conversion no longer writes LONG data into a SHORT variable and the sample still behaves correctly.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- databases, desktop
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 55/100