Two pointers pointing to the same address

c, c++, pointers

Solution

The fact itself is ok, but you'll run into undefined behavior if you call `delete` on one of the pointers and attempt to use the other afterwards:

int* x = new int(5);
int* y = x;
delete x;
//y is a dangling pointer

If you run into a situation where you have to use multiple pointers to the same memory address, you should look into smart pointers.

Problem

What happens when two pointers are pointing to the same address? Is this going to cause a security problem?

Original source