C++ Heap Corruption example
class A {
A(int i)
{
text = (char *)malloc(sizeof (char *)) ;
}
A()
{
text = (char *)malloc(sizeof (char *)) ;
}
virtual ~A()
{
if(text != 0)
{
free(text);
text = 0;
}
}
};
void main()
{
A a;
a = A(123);
}
A(int i)
{
text = (char *)malloc(sizeof (char *)) ;
}
A()
{
text = (char *)malloc(sizeof (char *)) ;
}
virtual ~A()
{
if(text != 0)
{
free(text);
text = 0;
}
}
};
void main()
{
A a;
a = A(123);
}
Comments