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);
}

Comments

Popular posts from this blog

Outlook : "operation failed, object could not be found. " when trying to close a PST.

How to transfer app and data from old iPhone to new iPhone for model IOS17 and IOS18 above.

Tips on how to use IBM iNotes (web client) on emailing or scheduling - Like copy tables from Excel or checking for user id (windows logon id) through email address