I just came across this blog post which mentions “stomping memory”:
a C++ program which is easily capable of stomping memory (something you prob
Other answers basically are correct, but I would like to give an example.
int a[10], i;
for (i = 0; i < 11 ; i++)
a[i] = 0;
int i, a[10];
for (i = 0; i < 11 ; i++)
a[i] = 0;
These samples may lead into infinite loop (or may not lead), because it is undefined behavior.
Very likely variable i
in memory is stored just after array. So accessing a[10]
could actually access i
in other words it could reset loop counter.
I think it is good example that demonstrates memory "stomping".