2020-04-19 16:00 UTC+0200 Przemyslaw Czerpak (druzus/at/poczta.onet.pl)

* src/vm/dynsym.c
  * src/vm/task.c
    ! pacified warnings

  * src/vm/hashfunc.c
    ! fixed possible GPF in hb_HCopy() and hb_HMerge() functions when source
      and destinnation is the same hash array.
This commit is contained in:
Przemysław Czerpak
2020-04-19 16:00:44 +02:00
parent b95b7abfdb
commit dc8fbceefe
4 changed files with 59 additions and 45 deletions

View File

@@ -510,7 +510,7 @@ static PHB_DYNS hb_dynsymGetByIndex( HB_LONG lIndex )
HB_DYNSYM_LOCK();
if( lIndex >= 1 && lIndex <= s_uiDynSymbols )
if( lIndex >= 1 && ( HB_ULONG ) lIndex <= s_uiDynSymbols )
pDynSym = s_pDynItems[ lIndex - 1 ].pDynSym;
HB_DYNSYM_UNLOCK();

View File

@@ -379,24 +379,26 @@ HB_FUNC( HB_HCOPY )
if( pSource && pDest )
{
HB_SIZE nLen = hb_hashLen( pSource ), nStart, nCount;
nStart = hb_parns( 3 );
if( ! nStart )
++nStart;
nCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : nLen - nStart + 1;
while( nCount-- )
if( pSource != pDest )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nStart );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nStart );
if( pKey && pValue )
hb_hashAdd( pDest, pKey, pValue );
else
break;
++nStart;
}
HB_SIZE nLen = hb_hashLen( pSource ), nStart, nCount;
nStart = hb_parns( 3 );
if( ! nStart )
++nStart;
nCount = HB_ISNUM( 4 ) ? ( HB_SIZE ) hb_parns( 4 ) : nLen - nStart + 1;
while( nCount-- )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nStart );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nStart );
if( pKey && pValue )
hb_hashAdd( pDest, pKey, pValue );
else
break;
++nStart;
}
}
hb_itemReturn( pDest );
}
else
@@ -410,36 +412,38 @@ HB_FUNC( HB_HMERGE )
if( pDest && pSource )
{
PHB_ITEM pAction = hb_param( 3, HB_IT_EVALITEM | HB_IT_NUMERIC );
if( pAction && HB_IS_EVALITEM( pAction ) )
if( pSource != pDest )
{
HB_SIZE nLen = hb_hashLen( pSource ), nPos = 0;
while( ++nPos <= nLen )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nPos );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nPos );
if( pKey && pValue )
{
hb_vmPushEvalSym();
hb_vmPush( pAction );
hb_vmPush( pKey );
hb_vmPush( pValue );
hb_vmPushSize( nPos );
hb_vmSend( 3 );
{
PHB_ITEM pReturn = hb_stackReturnItem();
if( HB_IS_LOGICAL( pReturn ) && hb_itemGetL( pReturn ) )
hb_hashAdd( pDest, pKey, pValue );
}
}
else
break;
}
}
else
hb_hashJoin( pDest, pSource, pAction ? hb_itemGetNI( pAction ) : HB_HASH_UNION );
PHB_ITEM pAction = hb_param( 3, HB_IT_EVALITEM | HB_IT_NUMERIC );
if( pAction && HB_IS_EVALITEM( pAction ) )
{
HB_SIZE nLen = hb_hashLen( pSource ), nPos = 0;
while( ++nPos <= nLen )
{
PHB_ITEM pKey = hb_hashGetKeyAt( pSource, nPos );
PHB_ITEM pValue = hb_hashGetValueAt( pSource, nPos );
if( pKey && pValue )
{
hb_vmPushEvalSym();
hb_vmPush( pAction );
hb_vmPush( pKey );
hb_vmPush( pValue );
hb_vmPushSize( nPos );
hb_vmSend( 3 );
{
PHB_ITEM pReturn = hb_stackReturnItem();
if( HB_IS_LOGICAL( pReturn ) && hb_itemGetL( pReturn ) )
hb_hashAdd( pDest, pKey, pValue );
}
}
else
break;
}
}
else
hb_hashJoin( pDest, pSource, pAction ? hb_itemGetNI( pAction ) : HB_HASH_UNION );
}
hb_itemReturn( pDest );
}
else

View File

@@ -756,6 +756,7 @@ void hb_taskResume( void * pTaskPtr )
#if defined( HB_HAS_UCONTEXT )
case TASK_INIT:
#endif
/* fallthrough */
case TASK_SUSPEND:
pTask->state = TASK_RUNNING;
/* fallthrough */