2009-08-29 13:33 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/include/hbcomp.h
  * harbour/source/compiler/hbmain.c
    ! fixed typo in -m parameter handling
    ! fixed old memory leak exploited by compile time error in code with
      static variables
This commit is contained in:
Przemyslaw Czerpak
2009-08-29 11:33:22 +00:00
parent c46621db36
commit d0845b91f5
3 changed files with 26 additions and 10 deletions

View File

@@ -17,6 +17,13 @@
past entries belonging to author(s): Viktor Szakats.
*/
2009-08-29 13:33 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcomp.h
* harbour/source/compiler/hbmain.c
! fixed typo in -m parameter handling
! fixed old memory leak exploited by compile time error in code with
static variables
2009-08-29 12:43 UTC+0200 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/include/hbcomp.h
* harbour/include/hbcompdf.h

View File

@@ -127,14 +127,15 @@ extern int hb_compVariableScope( HB_COMP_DECL, const char * );
/*
* flags for funFlags member
*/
#define FUN_STATEMENTS 0x01 /* Function have at least one executable statement */
#define FUN_USES_STATICS 0x02 /* Function uses static variables */
#define FUN_PROCEDURE 0x04 /* This is a procedure that shouldn't return value */
#define FUN_BREAK_CODE 0x08 /* last statement breaks execution flow */
#define FUN_USES_LOCAL_PARAMS 0x10 /* parameters are declared using () */
#define FUN_WITH_RETURN 0x20 /* there was RETURN statement in previous line */
#define FUN_EXTBLOCK 0x40 /* it's extended codeblock */
#define FUN_FILE_DECL 0x80 /* pseudo function with file wide declarations */
#define FUN_STATEMENTS 0x0001 /* Function have at least one executable statement */
#define FUN_USES_STATICS 0x0002 /* Function uses static variables */
#define FUN_PROCEDURE 0x0004 /* This is a procedure that shouldn't return value */
#define FUN_BREAK_CODE 0x0008 /* last statement breaks execution flow */
#define FUN_USES_LOCAL_PARAMS 0x0010 /* parameters are declared using () */
#define FUN_WITH_RETURN 0x0020 /* there was RETURN statement in previous line */
#define FUN_EXTBLOCK 0x0040 /* it's extended codeblock */
#define FUN_FILE_DECL 0x0080 /* pseudo function with file wide declarations */
#define FUN_ATTACHED 0x0100 /* function attached to function list */
extern void hb_compFunctionAdd( HB_COMP_DECL, const char * szFunName, HB_SYMBOLSCOPE cScope, int iType ); /* starts a new Clipper language function definition */
extern PFUNCTION hb_compFunctionFind( HB_COMP_DECL, const char * szFunName ); /* locates a previously defined function */

View File

@@ -1964,7 +1964,7 @@ void hb_compExternAdd( HB_COMP_DECL, const char * szExternName, HB_SYMBOLSCOPE c
static void hb_compAddFunc( HB_COMP_DECL, PFUNCTION pFunc )
{
while( HB_COMP_PARAM->functions.pLast &&
!HB_COMP_PARAM->functions.pLast->szName )
!HB_COMP_PARAM->functions.pLast->szName )
{
PFUNCTION pBlock = HB_COMP_PARAM->functions.pLast;
HB_COMP_PARAM->functions.pLast = pBlock->pOwner;
@@ -3831,6 +3831,7 @@ static void hb_compAddInitFunc( HB_COMP_DECL, PFUNCTION pFunc )
PCOMSYMBOL pSym = hb_compSymbolAdd( HB_COMP_PARAM, pFunc->szName, NULL, HB_SYM_FUNCNAME );
pSym->cScope |= pFunc->cScope;
pFunc->funFlags |= FUN_ATTACHED;
hb_compAddFunc( HB_COMP_PARAM, pFunc );
hb_compGenPCode1( HB_P_ENDPROC, HB_COMP_PARAM );
}
@@ -3883,6 +3884,13 @@ void hb_compCompileEnd( HB_COMP_DECL )
HB_COMP_PARAM->functions.pFirst = NULL;
}
if( HB_COMP_PARAM->pInitFunc &&
( HB_COMP_PARAM->pInitFunc->funFlags & FUN_ATTACHED ) == 0 )
{
hb_compFunctionKill( HB_COMP_PARAM, HB_COMP_PARAM->pInitFunc );
HB_COMP_PARAM->pInitFunc = NULL;
}
while( HB_COMP_PARAM->funcalls.pFirst )
{
PFUNCALL pFunc = HB_COMP_PARAM->funcalls.pFirst;
@@ -3974,7 +3982,7 @@ static int hb_compCompile( HB_COMP_DECL, const char * szPrg, const char * szBuff
else
hb_compModuleAdd( HB_COMP_PARAM,
hb_compIdentifierNew( HB_COMP_PARAM, szPrg, HB_IDENT_COPY ),
FALSE );
TRUE );
}
pModule = HB_COMP_PARAM->modules;