Comparing COleVariant objects
Patrice Buriez -- patriceb@businessline.tm.fr Wednesday, September 04, 1996 Environment: VC++ 4.1, NT 3.51 Version: #define _MFC_VER 0x0410, #define _MFC_BUILD 6038 I have just browsed the MFC source code of the COleVariant class, and I humbly think there is a potential bug when comparing COleVariant objects of type VT_ARRAY. In "msdev\mfc\src\olevar.cpp", line 228, the COleVariant::operator== relies on the static function CompareSafeArrays() to achieve comparison of VT_ARRAYs. In the implementation of this static function, lines 891-893 read: // Increment the element count nTotalElements *= (pUBound1[dwIndex] - pLBound1[dwIndex] + 1)/dwSize1; I cannot figure out the reason for this division by dwSize1 (previously obtained from SafeArrayGetElemsize()). May be I'm a fool... but I guess that this division results in an under-estimated number of elements in the arrays, which then results in comparing fewer elements than actually present in these arrays. Consequently, arrays that only differ on the last elements would compare OK... Any ideas ? Patrice ----- =8^) ------------------------------------------------------ Patrice BURIEZ Phone: +33 (1) 30 84 43 16 Fax: +33 (1) 30 84 44 59 Email: patriceb@businessline.tm.fr Visit: http://www.businessline.tm.fr ----------------------------------------------------------------- Disclaimer: Opinions expressed are my own and are not those of my employer. -----------------------------------------------------------------
Mike Blaszczak -- mikeblas@nwlink.com Thursday, September 05, 1996 At 07:18 PM 9/4/96 +0200, you wrote: >Environment: VC++ 4.1, NT 3.51 >Version: #define _MFC_VER 0x0410, #define _MFC_BUILD 6038 >I have just browsed the MFC source code of the COleVariant class, and I >humbly think there is a potential bug when comparing COleVariant objects of >type VT_ARRAY. >In "msdev\mfc\src\olevar.cpp", line 228, the COleVariant::operator== relies >on the static function CompareSafeArrays() to achieve comparison of VT_ARRAYs. > >In the implementation of this static function, lines 891-893 read: > // Increment the element count > nTotalElements *= > (pUBound1[dwIndex] - pLBound1[dwIndex] + 1)/dwSize1; > >I cannot figure out the reason for this division by dwSize1 (previously >obtained from SafeArrayGetElemsize()). It doesn't seem like MFC 4.2 has that same code. Maybe the whole algorithm chagned, maybe only this line changed... I don't have a free moment to compare the code and reverse engineer what is happening. .B ekiM http://www.nwlink.com/~mikeblas/ These words are my own. I do not speak on behalf of Microsoft.
| Вернуться в корень Архива |