diff --git a/harbour/ChangeLog b/harbour/ChangeLog index a3aa03cab8..2346821f01 100644 --- a/harbour/ChangeLog +++ b/harbour/ChangeLog @@ -8,7 +8,18 @@ 2002-12-01 13:30 UTC+0100 Foo Bar */ -2006-11-27 02:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) +2006-11-28 05:40 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) + * harbour/source/compiler/harbour.c + ! fixed typo in last modification which caused memory leak + + * harbour/source/vm/codebloc.c + + initialize freed codeblock structure with pointer to static PCODE + which returns NIL for buggy .prg destructors. + + * harbour/ChangeLog + ! fixed date of my last commit + +2006-11-28 02:10 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl) * harbour/tests/codebl.prg * harbour/tests/langmsg.prg * harbour/utils/hbpptest/pp_test.prg diff --git a/harbour/source/compiler/harbour.c b/harbour/source/compiler/harbour.c index 30027218f6..d63bcef947 100644 --- a/harbour/source/compiler/harbour.c +++ b/harbour/source/compiler/harbour.c @@ -4522,14 +4522,13 @@ static int hb_compCompile( HB_COMP_DECL, char * szPrg, BOOL bSingleFile ) if( HB_COMP_PARAM->pInitFunc ) { PCOMSYMBOL pSym; - char * szNewName; + char szNewName[ 25 ]; /* Fix the number of static variables */ HB_COMP_PARAM->pInitFunc->pCode[ 3 ] = HB_LOBYTE( HB_COMP_PARAM->iStaticCnt ); HB_COMP_PARAM->pInitFunc->pCode[ 4 ] = HB_HIBYTE( HB_COMP_PARAM->iStaticCnt ); HB_COMP_PARAM->pInitFunc->iStaticsBase = HB_COMP_PARAM->iStaticCnt; /* Update pseudo function name */ - szNewName = ( char * ) hb_xgrab( 25 ); sprintf( szNewName, "(_INITSTATICS%05d)", HB_COMP_PARAM->iStaticCnt ); HB_COMP_PARAM->pInitFunc->szName = hb_compIdentifierNew( HB_COMP_PARAM, szNewName, HB_IDENT_COPY ); diff --git a/harbour/source/vm/codebloc.c b/harbour/source/vm/codebloc.c index f4cd3af5b0..7d9337b05e 100644 --- a/harbour/source/vm/codebloc.c +++ b/harbour/source/vm/codebloc.c @@ -57,6 +57,13 @@ #include "hbapiitm.h" #include "hbvm.h" #include "hbstack.h" +#include "hbpcode.h" + +/* Dummy returning NIL for buggy code which may store references + to freed by GC codeblock in .prg destructors and then (after + catching RT EG_DESTRUCTOR error) try to execute them + */ +static const BYTE s_pCode[] = { HB_P_PUSHNIL, HB_P_ENDBLOCK }; /* Release all allocated memory when called from the garbage collector */ @@ -70,9 +77,10 @@ static HB_GARBAGE_FUNC( hb_codeblockDeleteGarbage ) */ if( pCBlock->pCode && pCBlock->dynBuffer ) { + pCBlock->dynBuffer = FALSE; hb_xfree( pCBlock->pCode ); - pCBlock->pCode = NULL; } + pCBlock->pCode = ( BYTE * ) s_pCode; /* free space allocated for local variables */