Bad Access error in c
===

I am trying write a function that loads a group of triangles from a file and add them to an array. Here is the definition of my triangle struct:  

    struct MYTriangle  
    {  
    MYVector a;  
    MYVector b;  
    MYVector c;  
    };  
    MYTriangle* triangles = NULL;  

Then I am reading the data from a file and create a triangle with that data(t). I have an int for counting the triangles too. In the below code I am trying to add triangles to the array but it gives me "bad access". Anyone can help me?  

    triangleCount++;  
    triangles = realloc(triangles, sizeof(MYTriangle) * triangleCount);  
    triangles[triangleCount - 1] = t;


