First make some canonical examples:
Memory leak
int *x; x = new int; x = nullptr;
We allocated an integer on the heap, and then we lost it. We have no way to call delete this integer at this point. This is a memory leak.
Hanging pointer
int *x; x = new int; delete x;
x now a dangling pointer. This indicates what used to be a valid memory. If we used *x at this moment, we would gain access to memory, which we should not be. Usually to resolve this issue after delete x; execute x = nullptr;
Your code
There is another problem in your code that I am going to shorten for your code so that we can more easily talk about the same thing:
int *x; x = new int[10]; x[9] = x[10];
I would describe it as none of the above cases. This is a buffer overflow.
source share