title: Program crashes when using free() on an array of structure that was created by calloc
body: <p>I have this function which is using <code>calloc</code> to create an array of structure <code>proposition</code>. Whenever I try to <code>free</code> the resulting array from another fuction, it crashes.</p>
  <pre><code>proposition* get_matching_propositions(char *pcde, proposition *propositions, int *match_count)
  {    
      proposition *matches;
      int         count       = get_count_from_stream(ptf_proposition, sizeof(proposition)),
                  cptr_match  = 0;
  
      for (int i = 0; i &lt; count; i++)
      {
          if (strcmp(propositions[i].cde, pcde) == NULL)
          {
              cptr_match++;
          }
      }
  
      matches = (proposition*) calloc (cptr_match, sizeof(propositions));
      assert(matches != NULL);
  
      cptr_match = 0;
      for (int i = 0; i &lt; count; i++)
      {
          if (strcmp(propositions[i].cde, pcde) == NULL)
          {
              matches[cptr_match] = propositions[i];
              cptr_match++;
          }
      }
      *match_count = cptr_match;
      return matches;
  }
  </code></pre>
  <p>Inside some other function I have:</p>
  <pre><code>proposition *matches =
      get_matching_propositions(current_question.cde, propositions, &amp;match_count);
  free(matches);
  </code></pre>
  <p>Then the program crashes with this message :<br />
  <code>Process returned -1073740940 (0xC0000374)   execution time : 1.370 s.</code></p>