yegord / snowman

Snowman decompiler

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Variable value can change when address is taken

rfalke opened this issue · comments

Subject: https://github.com/rfalke/decompiler-subjects/tree/master/from_holdec/change_local_via_function/ia32_elf

Source:

int main() {
    int x=41;
    inc(&x);
    printf("The answer should be 42 and is %d\n", x);
    return 0;
}

Output:

int32_t main() {
    int32_t* v1;

    v1 = reinterpret_cast<int32_t*>((reinterpret_cast<uint32_t>(__zero_stack_offset()) & 0xfffffff0) - 4 - 4 - 12);
    inc(v1);
    fun_8049040("The answer should be 42 and is %d\n", 41, 0x8049081, v1);
    return 0;
}

The 41 in the printf call is wrong.

Also:

  • doesn't recognize fun_8049040 as printf
  • doesn't create a variable to hold the "real" value instead of some pointer.