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:
parent
377e63b038
commit
c39fc5e742
@ -117,7 +117,7 @@ static yamop *code_p;
|
||||
|
||||
static CODEADDR code_addr;
|
||||
static int pass_no;
|
||||
static int *label_offset;
|
||||
int *label_offset;
|
||||
static OPREG var_offset;
|
||||
static int is_y_var;
|
||||
|
||||
@ -2392,6 +2392,9 @@ do_pass(void)
|
||||
save_machine_regs();
|
||||
longjmp(CompilerBotch,3);
|
||||
}
|
||||
|
||||
if ( (char *)(label_offset+cpc->rnd1) > freep)
|
||||
freep = (char *)(label_offset+cpc->rnd1);
|
||||
label_offset[cpc->rnd1] = (CELL) code_p;
|
||||
}
|
||||
/* 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
|
||||
* produces the final version of the code
|
||||
*/
|
||||
int *workspace = (int *)freep;
|
||||
CELL size;
|
||||
|
||||
code_addr = NIL;
|
||||
assembling = mode;
|
||||
label_offset = workspace;
|
||||
label_offset = (int *)freep;
|
||||
pass_no = 0;
|
||||
asm_error = FALSE;
|
||||
do_pass();
|
||||
|
2
C/grow.c
2
C/grow.c
@ -654,6 +654,8 @@ growheap(int fix_code)
|
||||
BlobsStart = cpc = (PInstr *)GlobalAddrAdjust((ADDR)cpc);
|
||||
}
|
||||
fix_compiler_instructions(cpc);
|
||||
freep = (char *)GlobalAddrAdjust((ADDR)freep);
|
||||
label_offset = (int *)GlobalAddrAdjust((ADDR)label_offset);
|
||||
}
|
||||
#ifdef TABLING
|
||||
fix_tabling_info();
|
||||
|
@ -263,6 +263,8 @@ extern PInstr *icpc, *BlobsStart;
|
||||
|
||||
extern char *freep, *freep0;
|
||||
|
||||
extern int *label_offset;
|
||||
|
||||
extern int IPredArity;
|
||||
|
||||
extern jmp_buf CompilerBotch;
|
||||
|
Reference in New Issue
Block a user