diff --git a/ChangeLog.txt b/ChangeLog.txt index 4f2e791847..0d4fb7666d 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -10,6 +10,12 @@ * Change, ! Fix, % Optimization, + Addition, - Removal, ; Comment */ +2017-05-10 07:50 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) + * contrib/hbwin/olecore.c + * added additional protection to reduce hb_oleSafeArrayToString() + functionality to arrays of VT_I1 and VT_UI1 items so other types + which may also allocate 1 byte for each item are not converted. + 2017-05-09 17:04 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl) * contrib/hbwin/olecore.c % small optimization in hb_oleSafeArrayFromString() diff --git a/contrib/hbwin/olecore.c b/contrib/hbwin/olecore.c index 0a3e8ccc61..49818e79a4 100644 --- a/contrib/hbwin/olecore.c +++ b/contrib/hbwin/olecore.c @@ -408,11 +408,15 @@ static SAFEARRAY * hb_oleSafeArrayFromString( PHB_ITEM pItem, VARTYPE vt ) return pSafeArray; } + static HB_BOOL hb_oleSafeArrayToString( PHB_ITEM pItem, SAFEARRAY * pSafeArray ) { long lFrom, lTo; + VARTYPE vt; if( SafeArrayGetElemsize( pSafeArray ) == 1 && + SafeArrayGetVartype( pSafeArray, &vt ) == S_OK && + ( vt == VT_I1 || vt == VT_UI1 ) && SafeArrayGetLBound( pSafeArray, 1, &lFrom ) == S_OK && SafeArrayGetUBound( pSafeArray, 1, &lTo ) == S_OK && lFrom <= lTo + 1 ) /* accept empty arrays */ @@ -427,6 +431,8 @@ static HB_BOOL hb_oleSafeArrayToString( PHB_ITEM pItem, SAFEARRAY * pSafeArray ) } return HB_FALSE; } + + static VARIANT * hb_oleVariantParam( int iParam ) { VARIANT * pVariant = ( VARIANT * ) hb_parptrGC( &s_gcVariantFuncs, iParam );