--- gforth/engine/main.c 2003/11/06 10:23:31 1.129 +++ gforth/engine/main.c 2003/11/06 21:59:49 1.130 @@ -267,15 +267,16 @@ unsigned char *branch_targets(Cell *imag int size, Cell base) /* produce a bitmask marking all the branch targets */ { - int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS; + int i=0, j, k, steps=(((size-1)/sizeof(Cell))/RELINFOBITS)+1; Cell token; unsigned char bits; - unsigned char *result=malloc(steps+1); - - memset(result, 0, steps+1); - for(k=0; k<=steps; k++) { + unsigned char *result=malloc(steps); + + memset(result, 0, steps); + for(k=0; k=base) { /* relocatable address */ UCell bitnum=(token-base)/sizeof(Cell); @@ -290,7 +291,7 @@ unsigned char *branch_targets(Cell *imag void relocate(Cell *image, const unsigned char *bitstring, int size, Cell base, Label symbols[]) { - int i=0, j, k, steps=(size/sizeof(Cell))/RELINFOBITS; + int i=0, j, k, steps=(((size-1)/sizeof(Cell))/RELINFOBITS)+1; Cell token; char bits; Cell max_symbols; @@ -317,12 +318,12 @@ void relocate(Cell *image, const unsigne for (max_symbols=0; symbols[max_symbols]!=0; max_symbols++) ; max_symbols--; - size/=sizeof(Cell); - for(k=0; k<=steps; k++) { + for(k=0; k