glibc detected *** free() invalid pointer
<p>Hi friends i am getting this error whwn i am running my code  "glibc detected <em>*</em> free() invalid pointer" in my code i am creating 3 pointer and allocating memory to only one using new and deleting all the three pointer. </p>

<pre><code>class test()
{
public : 
int a;
/..some functionality../

}; 

class second_test()
{
public : 
int b;
/..some functionality../
} 

  class third_test()
    {
    public : 
    int c;
    /..some functionality../
    } 




int main()
{
test *ptrtest;
second_test *psecond_test;
third_test*pthird_test;



ptrtest = new test;
/..Doing some functionality.../


delete ptrtest;
   delete psecond_test;
delete pthird_test;


}
</code></pre>

<p>and when i am running it is giving above error but surprisingly not al the time it is giving error 7 out nof 10 time it gives above error..please help me what exactly the problem.
 BECAUSE in c++ i think it is safe to delete NULL pointer.</p>
