FIX: DFX_Bool Calls Default() with AFX_RFX_LONGBINARY (150789)
The information in this article applies to:
- Microsoft Visual C++ 4.0
- Microsoft Visual C++ 4.1
- Microsoft Foundation Classes (MFC)
This article was previously published under Q150789 SYMPTOMS
Memory adjacent to the BOOL variable gets overwritten when working with a
BOOL CDaoRecordset field data member.
CAUSE
The DFX_Bool function delegates the Fixup case to
CDaoFieldExchange::Default and incorrectly passes AFX_RFX_LONGBINARY as the
field data type.
RESOLUTION
To resolve this problem, copy the DFX_Bool function to the project and give
it a different name. For example, rename it DFX_Bool2. In the call to
CDaoFieldExchange::Default, change the field data type from
AFX_RFX_LONGBINARY to AFX_RFX_BOOL by using the following code:
Change this code
case CDaoFieldExchange::Fixup:
// Convert BOOL value from AFX_DAO_TRUE/FALSE to TRUE/FALSE
value = (value != AFX_DAO_FALSE);
pFX->Default(lpszName, (void*)&value,
AFX_RFX_LONGBINARY, dwBindOptions);
return;
to this code:
case CDaoFieldExchange::Fixup:
// Convert BOOL value from AFX_DAO_TRUE/FALSE to TRUE/FALSE
value = (value != AFX_DAO_FALSE);
pFX->Default(lpszName, (void*)&value,
AFX_RFX_BOOL, dwBindOptions); // <<-- Change to AFX_RFX_BOOL
return;
Then, change the class of the CDaoRecordset-derived DoFieldExchange
function to call this new function in place of calling DFX_Bool.
STATUS
Microsoft has confirmed this to be a bug in the Microsoft products
listed at the beginning of this article. This bug was corrected in Visual
C++ 32-bit Edition version 4.2.
Modification Type: | Major | Last Reviewed: | 11/18/2003 |
---|
Keywords: | kbbug kbDatabase kbfix KB150789 |
---|
|