title: free() loop, is triggering a break point and seems to not free the element
body: <p>I have been working on an assignment which is pretty much done, and all I need to do is free the the double pointer allocated memory, but with the loop when I go through the loop it triggers a break point and seems to not clear it all I'm not sure whats triggering it.
  Context: the Create Data function is basically a function that returns a malloc.    </p>
  
  <pre><code>int main(void){
  
  
  
  int i;
      static STUDENT** records; 
      static float averageTotal[SIZE];
      createData(); 
      records = calloc(3, sizeof(STUDENT*));
      for (i = 0; i &lt; 3; i++){
          records[i] = createData();
      }
  
      menu(records, userinput, &amp;averageTotal[0]); 
      int c;
      for (c = 0; c &lt; 3; c++){
  
  
              free(records[c]);
  
  
      }
      free(records);
  
  
      return 0;
  
  }
  STUDENT* createData()
  {
      STUDENT* result;
      result = malloc(3*sizeof(STUDENT*));
      return result;
  }
  </code></pre>
  
  <p>EDIT: added Menu for Context</p>
  
  <pre><code>void menu(STUDENT* records, int user_size, float* averageTotal[]){
      int menuV = 0;
      do{
  
          int userinput;  
          int i;
          static int counter = 0;
          printf("       **********************************\n");
          printf("       *        MENU                    *\n");
          printf("       *  1. Add Student                *\n");
          printf("       *  2. Display all student records*\n");
          printf("       *  3. Quit                       *\n");
          printf("       **********************************\n");
          scanf_s("%d%*[^\n]", &amp;userinput); '\n' == getchar();
          switch (userinput){
              // switch statement with loops.
          case 1:do
          {
              addStudent(records, &amp;counter, user_size);
              printf("Add another record? 1(y) 2(n)\n");
              scanf_s("%d%*[^\n]", &amp;userinput); '\n' == getchar();
          } while (userinput == 1);
          break;
          case 2:
          do{
              displayStudent(records, user_size);
              printf("Display again? 1(y) 2(n)\n");
              scanf_s("%d%*[^\n]", &amp;userinput); '\n' == getchar();
          } while (userinput == 1);
          break;
  
          case 3:
              menuV++;
                  break;
  
  
  
  
  
          }
      } while (menuV == 0);
  }
  </code></pre>
  
  <p>Edit: added addStudent Function for Context</p>
  
  <pre><code>void addStudent(STUDENT* records[], int* counter, int user_size)
  
  { // A simple function that lets the user add values to the struct. The counter keeps track and changes the element.
      printf("Student: %d", (*counter+1));
      printf(" of 3\n");
      printf("Enter name:\n");
      fgets(records[*counter]-&gt;name, 40, stdin);
      printf("Enter Exam 1 Score: \n");
      scanf_s("%f", &amp;records[*counter]-&gt;exam1); 
      printf("Enter Exam 2 Score: \n");
      scanf_s("%f", &amp;records[*counter]-&gt;exam2);
      printf("Name:%s",records[*counter]-&gt;name);
      printf("Exam 1:%0.2f\n", records[*counter]-&gt;exam1);
      printf("Exam 2:%0.2f\n", records[*counter]-&gt;exam2);
      (*counter)++;
  
  
  }
  </code></pre>