title: malloc: *** error for object: pointer being freed was not allocated *** set a breakpoint in malloc_error_break to debug
body: <p>Can someone help me figure out where I'm getting this error. I know it's probably a double deletion or something like this. For the background this is an implementation of the huffman's tree as you can easily realize on <a href="http://en.wikipedia.org/wiki/Huffman_coding" rel="noreferrer">wikipedia</a>.</p>
  
  <p><a href="http://pastebin.com/6CM9eman" rel="noreferrer">CharCountNode class implementation</a></p>
  
  <pre><code>int main()
  {
    ifstream input;
    input.open("input.txt");
  
    MinPriorityQueue&lt;CharCountNode&gt; heap;
    map&lt;char, int&gt; m;
  
    while(input.good())
      m[input.get()] += 1;
  
    for( map&lt;char, int&gt;::const_iterator it = m.begin(); it != m.end(); ++it )
      heap.enqueue(CharCountNode(it-&gt;first, it-&gt;second));
  
  
    while(heap.getSize() &gt; 1)
    {
      CharCountNode a, b, parent;
  
      a = heap.dequeue();
      b = heap.dequeue();
      parent = CharCountNode('*', a.getCount() + b.getCount());
  
      parent.left = &amp;a;
      parent.right = &amp;b;
  
      heap.enqueue(parent);
    }
  }
  </code></pre>