title: malloc(): mismatching next->prev_size (unsorted)
body: <p>After trying several ways to erase specific pointers from a vector, now I get this error.
  I'm using a double for loop to find the objects I need to erase. I'm doing something like this:</p>
  
  <pre><code>for(i=0; i&lt;vectorfromClassA.size();i++){
      for(j=0; j&lt;vectorfromClassB.size();j++){
  
           if(condition == true){
              delete vectorfromClassA[i]-&gt;vectorfromClassB[j];
              vectorfromClassA[i]-&gt;vectorfromClassB[j] = nullptr;
           }
  
      }
  }
  </code></pre>
  
  <p>And then I'm using the erase-remove idiom like this after I finish to iterate class B vector:</p>
  
  <pre><code>vectorfromClassA-&gt;vectorfromClassB.erase(
      remove_if(
          vectorfromClassB.begin(), 
          vectorfromClassB.end(), 
          [](classB * b){return b == nullptr}));
  </code></pre>
  
  <p>After that, I can print the vector, but the error appears equally. If don't use the erase-remove, I can add new values to my vector, but the new value that I've tried to add appears twice. I think this could be because of the memory space from the vector is still there if don't erase it.</p>
  
  <p>Can anyone help me to see the light?
  Thank you and forgive me if I'm asking anything too obvious, as I said in my first post I'm new with all this stuff. </p>