diff --git a/harbour/ChangeLog b/harbour/ChangeLog index 73b224ad81..a32c12fc46 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -1,3 +1,19 @@ +2001-01-09 16:15 UTC+0100 Ryszard Glab + + *source/rdd/workarea.c + *codeblocks used in SET LOCATE are properly locked/unlocked + to prevent deallocation by the GC + (thanks to shashkov@orel.ru) + + *source/vm/macro.c + *fixed bug in hb_macroTextSubst() (result buffer reallocation) + (thanks to shashkov@orel.ru) + + *source/vm/memvars.c + *fixed access of uninitialized memvar values + (thanks to shashkov@orel.ru) + + 2001-01-08 17:45 UTC-0800 Ron Pinkas * source/pp/ppcore.c ! Fixed ')' as expression terminator in state STATE_ID_END diff --git a/harbour/source/rdd/workarea.c b/harbour/source/rdd/workarea.c index 09b8345438..607c6cd883 100644 --- a/harbour/source/rdd/workarea.c +++ b/harbour/source/rdd/workarea.c @@ -852,6 +852,7 @@ ERRCODE hb_waClearLocate( AREAP pArea ) /* Free all items */ if( pArea->dbsi.itmCobFor ) { + hb_gcUnlockItem( pArea->dbsi.itmCobFor ); hb_itemRelease( pArea->dbsi.itmCobFor ); pArea->dbsi.itmCobFor = NULL; } @@ -862,6 +863,7 @@ ERRCODE hb_waClearLocate( AREAP pArea ) } if( pArea->dbsi.itmCobWhile ) { + hb_gcUnlockItem( pArea->dbsi.itmCobWhile ); hb_itemRelease( pArea->dbsi.itmCobWhile ); pArea->dbsi.itmCobWhile = NULL; } @@ -935,13 +937,19 @@ ERRCODE hb_waSetLocate( AREAP pArea, LPDBSCOPEINFO pScopeInfo ) SELF_CLEARLOCATE( pArea ); if( pScopeInfo->itmCobFor ) + { pArea->dbsi.itmCobFor = hb_itemNew( pScopeInfo->itmCobFor ); + hb_gcLockItem( pArea->dbsi.itmCobFor ); + } if( pScopeInfo->lpstrFor ) pArea->dbsi.lpstrFor = hb_itemNew( pScopeInfo->lpstrFor ); if( pScopeInfo->itmCobWhile ) + { pArea->dbsi.itmCobWhile = hb_itemNew( pScopeInfo->itmCobWhile ); + hb_gcLockItem( pArea->dbsi.itmCobWhile ); + } if( pScopeInfo->lpstrWhile ) pArea->dbsi.lpstrWhile = hb_itemNew( pScopeInfo->lpstrWhile ); @@ -970,7 +978,7 @@ ERRCODE hb_waCompile( AREAP pArea, BYTE * pExpr ) pMacro = hb_macroCompile( ( char * ) pExpr ); if( pMacro ) { - hb_itemPutPtr( pArea->valResult, ( void * ) pMacro ); + pArea->valResult = hb_itemPutPtr( pArea->valResult, ( void * ) pMacro ); return SUCCESS; } else diff --git a/harbour/source/vm/macro.c b/harbour/source/vm/macro.c index 039ee87d59..d030eda903 100644 --- a/harbour/source/vm/macro.c +++ b/harbour/source/vm/macro.c @@ -353,8 +353,12 @@ char * hb_macroTextSubst( char * szString, ULONG *pulStringLen ) ulResStrLen += ( ulValLen - ulNameLen ); if( ulResStrLen > ulResBufLen ) { + ULONG ulHead = pHead - szResult; + ULONG ulTail = pTail - szResult; ulResBufLen = ulResStrLen; szResult = ( char * ) hb_xrealloc( szResult, ulResBufLen + 1 ); + pHead = szResult + ulHead; + pTail = szResult + ulTail; } } else diff --git a/harbour/source/vm/memvars.c b/harbour/source/vm/memvars.c index 28d4108083..6ba6596643 100644 --- a/harbour/source/vm/memvars.c +++ b/harbour/source/vm/memvars.c @@ -107,14 +107,13 @@ void hb_memvarsRelease( void ) if( s_globalTable ) { - while( ulCnt ) + while( --ulCnt ) { if( s_globalTable[ ulCnt ].counter && s_globalTable[ ulCnt ].hPrevMemvar != ( HB_HANDLE )-1 ) { hb_itemClear( &s_globalTable[ ulCnt ].item ); s_globalTable[ ulCnt ].counter = 0; } - --ulCnt; } } } @@ -271,12 +270,15 @@ void hb_memvarSetPrivatesBase( ULONG ulBase ) { --s_privateStackCnt; hVar = s_privateStack[ s_privateStackCnt ]->hMemvar; - hOldValue = s_globalTable[ hVar ].hPrevMemvar; - hb_memvarValueDecRef( hVar ); - /* - * Restore previous value for variables that were overridden - */ - s_privateStack[ s_privateStackCnt ]->hMemvar = hOldValue; + if( hVar ) + { + hOldValue = s_globalTable[ hVar ].hPrevMemvar; + hb_memvarValueDecRef( hVar ); + /* + * Restore previous value for variables that were overridden + */ + s_privateStack[ s_privateStackCnt ]->hMemvar = hOldValue; + } } s_privateStackBase = ulBase; } @@ -1506,7 +1508,7 @@ void hb_memvarsIsMemvarRef( void ) { ULONG ulCnt = s_globalLastFree; - while( ulCnt ) + while( --ulCnt ) { /* do not check detached variables - for these variables only * references from the eval stack are meaningfull for the GC @@ -1515,7 +1517,6 @@ void hb_memvarsIsMemvarRef( void ) { hb_gcItemRef( &s_globalTable[ ulCnt ].item ); } - --ulCnt; } } }