Local Variables Local variables are stored on the stack - they are allocated by a simple update of the stack pointer - they are not automatically initialized - this is why they contain random data, that was present in the memory locations they occupy. Since all local variables of a function are stored in consecutive memory on the stack, if we take a pointer to such a variable and then write just above or below it, we will over-write the contents of another local variable (or even the function's return address).