title: Segmentation fault on the line operator new
body: <p>Perfect obscure bug in the function <code>realloc_aray()</code>. In the line <code>node * b = new node [size];</code> program crashes with segmentation fault. It is not clear why the program falls on the operator new. I debugged it in GDB. The value of the variable <code>size = 9</code>, that is the reason is not a lack of memory ... ?</p>
  
  <pre><code>void compress::compresser::compress_string(const std::string&amp; s, std::string&amp; t)
  {
      std::vector&lt;std::string&gt; r;
      tokenize(s, r);
      int l = r.size() - 1;
      node tt[l][l];    
      node* a = new node[l];
      for(int i = 0; i &lt; l; ++i)
      {
           node* rr = m_tree-&gt;get_new_node(atoi(r[i].c_str()));
           a[i] = *rr;
      }
      int m = dec_to_bin(l); 
      node* b = get_xor_array(a, l);
  //  delete [] a;
      for(int i = 0; i &lt; m; ++i )
      {
          for(int j = 0; j &lt; l; j+=2)
          {
              node* n = m_tree-&gt;get_new_xor_node(&amp;b[j], &amp;b[j + 1]);
              tt[i][j] = *n;
              delete n;               
          }
          l = l/2; 
  //      delete [] b;
          b = get_xor_array(tt[i], l);            
      }
  }
  
  compress::node* compress::compresser::get_xor_array(const node* const a, int  size)
  {
      node* b = 0;
      b = realloc_array(a, size);
      return b;
  }
  
  compress::node* compress::compresser::realloc_array(const node* const a, int size)
  {
      int i = 0;
      node* b = new node[size]; // in this line program crashes with segmentation fault
      for(i = 0; i &lt; size; ++i)
      {
          b[i] = a[i];
      }
      b[size] = 0;
      return b;
  }
  </code></pre>