2010-09-10 09:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/contrib/hbwin/olecore.c
    ! do not convert parameters passed by reference for DISPID_PROPERTYPUT
      It should fix potential memory leak because in such case we do not
      use PutParams() which release them.
    ! return assigned value instead of index in __OPINDEX() method.
This commit is contained in:
Przemyslaw Czerpak
2010-09-10 07:58:01 +00:00
parent 15b23e3746
commit e79bb83514
2 changed files with 24 additions and 14 deletions

View File

@@ -16,6 +16,13 @@
The license applies to all entries newer than 2009-04-28.
*/
2010-09-10 09:57 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbwin/olecore.c
! do not convert parameters passed by reference for DISPID_PROPERTYPUT
It should fix potential memory leak because in such case we do not
use PutParams() which release them.
! return assigned value instead of index in __OPINDEX() method.
2010-09-10 05:14 UTC+0300 Mindaugas Kavaliauskas (dbtopas/at/dbtopas.lt)
* harbour/contrib/hbwin/olecore.c
* harbour/contrib/hbwin/oleauto.prg

View File

@@ -1162,7 +1162,7 @@ HB_BOOL hb_oleDispInvoke( PHB_SYMB pSym, PHB_ITEM pObject, PHB_ITEM pParam,
/* IDispatch parameters, return value handling */
static void GetParams( DISPPARAMS * dispparam )
static void GetParams( DISPPARAMS * dispparam, HB_BOOL fUseRef )
{
VARIANTARG *pArgs = NULL, *pRefs;
UINT uiArgCount, uiArg, uiRefs;
@@ -1172,10 +1172,13 @@ static void GetParams( DISPPARAMS * dispparam )
if( uiArgCount > 0 )
{
uiRefs = 0;
for( uiArg = 1; uiArg <= uiArgCount; uiArg++ )
if( fUseRef )
{
if( HB_ISBYREF( uiArg ) )
uiRefs++;
for( uiArg = 1; uiArg <= uiArgCount; uiArg++ )
{
if( HB_ISBYREF( uiArg ) )
uiRefs++;
}
}
pArgs = ( VARIANTARG* ) hb_xgrab( sizeof( VARIANTARG ) * ( uiArgCount + uiRefs ) );
@@ -1184,7 +1187,7 @@ static void GetParams( DISPPARAMS * dispparam )
for( uiArg = 0; uiArg < uiArgCount; uiArg++ )
{
VariantInit( &pArgs[ uiArg ] );
if( HB_ISBYREF( uiArgCount - uiArg ) )
if( fUseRef && HB_ISBYREF( uiArgCount - uiArg ) )
{
VariantInit( pRefs );
hb_oleItemToVariantRef( pRefs, hb_param( uiArgCount - uiArg, HB_IT_ANY ),
@@ -1512,7 +1515,7 @@ HB_FUNC( WIN_OLEAUTO___ONERROR )
DISPID lPropPut = DISPID_PROPERTYPUT;
memset( &excep, 0, sizeof( excep ) );
GetParams( &dispparam );
GetParams( &dispparam, HB_FALSE );
dispparam.rgdispidNamedArgs = &lPropPut;
dispparam.cNamedArgs = 1;
@@ -1542,7 +1545,7 @@ HB_FUNC( WIN_OLEAUTO___ONERROR )
{
memset( &excep, 0, sizeof( excep ) );
VariantInit( &variant );
GetParams( &dispparam );
GetParams( &dispparam, HB_TRUE );
lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_( pDisp ) dispid, HB_ID_REF( IID_NULL ),
LOCALE_USER_DEFAULT,
@@ -1590,7 +1593,7 @@ HB_FUNC( WIN_OLEAUTO___OPINDEX )
if( !pDisp )
return;
fAssign = hb_pcount() != 1;
fAssign = hb_pcount() > 1;
if( fAssign )
{
@@ -1598,7 +1601,7 @@ HB_FUNC( WIN_OLEAUTO___OPINDEX )
DISPID lPropPut = DISPID_PROPERTYPUT;
memset( &excep, 0, sizeof( excep ) );
GetParams( &dispparam );
GetParams( &dispparam, HB_FALSE );
dispparam.rgdispidNamedArgs = &lPropPut;
dispparam.cNamedArgs = 1;
@@ -1609,14 +1612,14 @@ HB_FUNC( WIN_OLEAUTO___OPINDEX )
FreeParams( &dispparam );
/* assign method should return assigned value */
hb_itemReturn( hb_param( 1, HB_IT_ANY ) );
hb_itemReturn( hb_param( hb_pcount(), HB_IT_ANY ) );
}
else
{
/* Access */
memset( &excep, 0, sizeof( excep ) );
VariantInit( &variant );
GetParams( &dispparam );
GetParams( &dispparam, HB_TRUE );
lOleError = HB_VTBL( pDisp )->Invoke( HB_THIS_( pDisp ) DISPID_VALUE, HB_ID_REF( IID_NULL ),
LOCALE_USER_DEFAULT,
@@ -1635,7 +1638,7 @@ HB_FUNC( WIN_OLEAUTO___OPINDEX )
if( lOleError != S_OK )
{
/* Try to detect if object is a collection */
memset( &excep, 0, sizeof( excep ) );
memset( &dispparam, 0, sizeof( dispparam ) );
VariantInit( &variant );
@@ -1644,8 +1647,8 @@ HB_FUNC( WIN_OLEAUTO___OPINDEX )
DISPATCH_PROPERTYGET,
&dispparam, &variant, &excep, &uiArgErr );
VariantClear( &variant );
hb_errRT_OLE( lOleErrorEnum == S_OK ? EG_BOUND : EG_ARG, 1016, ( HB_ERRCODE ) lOleError, NULL,
hb_errRT_OLE( lOleErrorEnum == S_OK ? EG_BOUND : EG_ARG, 1016, ( HB_ERRCODE ) lOleError, NULL,
hb_langDGetErrorDesc( fAssign ? EG_ARRASSIGN : EG_ARRACCESS ) );
}
}