Branch: Tag:

2015-02-19

2015-02-19 12:45:13 by Henrik Grubbström (Grubba) <grubba@grubba.org>

Compiler [amd64]: Fix bug in F_FOREACH.

The initial foreach counter may be set to non-zero when foreach goes
over a ranged array. If the initial foreach counter is larger than
the size of the array F_FOREACH started indexing outside the array.

Fixes [bug 7426 (#7426)].

FIXME: Is there a corresponding problem with negative ranges?

2789:    mov_mem_reg( sp_reg, -4*sizeof(struct svalue)+8, P_REG_RBX );    mov_mem32_reg( P_REG_RBX, OFFSETOF(array,size), P_REG_RCX );    cmp_reg_reg( P_REG_RAX, P_REG_RCX ); -  je(&label_A); +  jge(&label_A);       /* increase counter */    add_mem_imm( sp_reg, -1*(int)sizeof(struct svalue)+8, 1 );