I saw a common practice of deleting the pointer amd making it null in destructor even if no memory is allocated to pointer on heap. Consider below C++ code:
dummy.h
class dummy
{
int* a;
}
dummy.cpp
dummy::dummy():a(NULL)
{ cout<<Inside Const"; }
dummy::~dummy()
{
if(a!=NULL)
{
delete a;
a = NULL;
}
}
bool func()
{
a = func1();
}
In above code although memory to a is not allocated on heap, even then it is deleted. It should not lead to memory leak?