Name:
Anonymous
2009-06-18 3:05
would this cause heap corruption?
int main()
{
char *s = new char[4];
delete &s[0];
delete [] s;
return 0;
}
Name:
Anonymous
2009-06-18 4:36
Now if you did a
int main()
{
char *s = new char[4];
memcpy(s,"deadbeef",sizeof(char) * 8);
delete s;
return 0;
}
You'd get something a bit more fun (probably a write AV)
int main()
{
char *s = new char[4];
char *t = new char[10];
memcpy(s,"deadbeef",sizeof(char) * 8);
delete s;
return 0;
}
This'll probably give you some heap corruption.