Fix bug causing functions with 254 bytes of locals to crash on return.

This was a bug with the code for moving the return address. It would generate a "LDA 0" instruction when it was trying to load the value at DP+256.

The following program (derived from a csmith-generated test case) demonstrates the crash:

#pragma optimize 8
int main (int argc, char **argv) {
    char s[0xFC];
}
This commit is contained in:
Stephen Heumann 2018-03-26 23:30:26 -05:00
parent 21493271b9
commit 29de867039
1 changed files with 1 additions and 1 deletions

View File

@ -5091,7 +5091,7 @@ procedure GenTree {op: icptr};
{if anything needs to be removed from the stack, move the return val}
size := localSize + parameterSize;
if parameterSize <> 0 then begin
if localSize > 254 then begin
if localSize > 253 then begin
GenNative(m_ldx_imm, immediate, localSize+1, nil, 0);
GenNative(m_lda_dirx, direct, 0, nil, 0);
GenNative(m_ldy_dirx, direct, 1, nil, 0);