fix heap overflow while indexing (label_array was not being copied properly)

git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@197 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
vsc 2001-11-25 21:44:42 +00:00
parent 377e63b038
commit c39fc5e742
3 changed files with 9 additions and 3 deletions

View File

@ -117,7 +117,7 @@ static yamop *code_p;
static CODEADDR code_addr; static CODEADDR code_addr;
static int pass_no; static int pass_no;
static int *label_offset; int *label_offset;
static OPREG var_offset; static OPREG var_offset;
static int is_y_var; static int is_y_var;
@ -2392,6 +2392,9 @@ do_pass(void)
save_machine_regs(); save_machine_regs();
longjmp(CompilerBotch,3); longjmp(CompilerBotch,3);
} }
if ( (char *)(label_offset+cpc->rnd1) > freep)
freep = (char *)(label_offset+cpc->rnd1);
label_offset[cpc->rnd1] = (CELL) code_p; label_offset[cpc->rnd1] = (CELL) code_p;
} }
/* reset dealloc_found in case there was a branch */ /* reset dealloc_found in case there was a branch */
@ -2569,12 +2572,11 @@ assemble(int mode)
* computes labels offsets and total code size 2 - the second pass * computes labels offsets and total code size 2 - the second pass
* produces the final version of the code * produces the final version of the code
*/ */
int *workspace = (int *)freep;
CELL size; CELL size;
code_addr = NIL; code_addr = NIL;
assembling = mode; assembling = mode;
label_offset = workspace; label_offset = (int *)freep;
pass_no = 0; pass_no = 0;
asm_error = FALSE; asm_error = FALSE;
do_pass(); do_pass();

View File

@ -654,6 +654,8 @@ growheap(int fix_code)
BlobsStart = cpc = (PInstr *)GlobalAddrAdjust((ADDR)cpc); BlobsStart = cpc = (PInstr *)GlobalAddrAdjust((ADDR)cpc);
} }
fix_compiler_instructions(cpc); fix_compiler_instructions(cpc);
freep = (char *)GlobalAddrAdjust((ADDR)freep);
label_offset = (int *)GlobalAddrAdjust((ADDR)label_offset);
} }
#ifdef TABLING #ifdef TABLING
fix_tabling_info(); fix_tabling_info();

View File

@ -263,6 +263,8 @@ extern PInstr *icpc, *BlobsStart;
extern char *freep, *freep0; extern char *freep, *freep0;
extern int *label_offset;
extern int IPredArity; extern int IPredArity;
extern jmp_buf CompilerBotch; extern jmp_buf CompilerBotch;