title: Segmentation fault when using std::string
body: <p>I'm sing C++ to build a csv processor for study purposes and having some throuble with segmentation faults.
  This processor will have one main class (csvcontroller) that should be the instance of the current file. This class controls two structures. One of them (CsvLine) is a list of all file lines and the other one (CsvColumn) represents a list of all columns on each list.
  My segmentation fault happens when i try to write the column value into the struct but it only happens when i'm using strings. If we replace string for int, the processor runs the way i want.</p>
  
  <p>This is my code:</p>
  
  <p>csvcontroller.h:</p>
  
  <pre><code>#ifndef CSVCONTROLLER_H
  #define CSVCONTROLLER_H
  
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  using namespace std;
  
  
  typedef struct CsvLine{
  
      struct CsvLine* next = NULL;
      struct CsvColumn* first = NULL;
      struct CsvColumn* last = NULL;
      struct CsvLine* previous = NULL;
  
  };
  
  typedef struct CsvColumn{
  
      struct CsvColumn* previous = NULL;
      string value = NULL;
      struct CsvColumn* next = NULL;
  
  };
  
  
  class csvcontroller{
      public:
          bool loadfile(string file_location,char separator);
          bool savefile(string file_location,char separator);
          CsvLine* getFirst();
          CsvLine* getLast();
          CsvLine* addLine();
          void addColumn(CsvLine* line,string* value);
          int getCount();
      protected:
          string path;
          CsvLine* first = NULL;
          CsvLine* last = NULL;
          int line_count;
      private:
  };
  
  #endif // CSVCONTROLLER_H
  </code></pre>
  
  <p>csvcontroller.cpp</p>
  
  <pre><code>#include "csvcontroller.h"
  #include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;sstream&gt;
  
  using namespace std;
  
  bool csvcontroller::loadfile(string file_location,char separator){
  
      this-&gt;path = file_location;
      const char * path = this-&gt;path.c_str();
  
      //Initializing read stream
      ifstream file;
      file.open(path);
  
      //Reading our file
      while(!file.eof()){
  
          string line;
          std::getline(file,line);
          stringstream stream(line);
  
          if(!line.empty()){
  
              string col;
              CsvLine* ln = this-&gt;addLine();
  
              while(std::getline(stream,col,separator)){
                  this-&gt;addColumn(ln,&amp;col);
              }
  
          }//if(!line.empty
  
      }//while(!file.eof())
  
  
  
      return false;
  }
  
  CsvLine* csvcontroller::addLine(){
      CsvLine* item = (CsvLine*) malloc(sizeof(CsvLine));
  
      if(this-&gt;first == NULL){
  
          this-&gt;first = item;
          this-&gt;last = item;
  
      }else{
  
          this-&gt;last-&gt;next = item;
          item-&gt;previous = this-&gt;last;
          this-&gt;last = item;
  
      }
  }
  
  void csvcontroller::addColumn(CsvLine* line,string* value){
  
      CsvColumn* col = (CsvColumn*) malloc(sizeof(CsvColumn));
      col-&gt;value = value;//Here's the problem
  
      if(line-&gt;first == NULL){
  
          line-&gt;first = col;
          line-&gt;last = col;
  
      }else{
  
          line-&gt;last-&gt;next = col;
          col-&gt;previous = line-&gt;last;
          line-&gt;last = col;
  
      }
  
  }
  
  /*
   *  GET &amp; SET
   */
  
  CsvLine* csvcontroller::getFirst(){
      return this-&gt;first;
  }
  
  CsvLine* csvcontroller::getLast(){
      return this-&gt;last;
  }
  </code></pre>
  
  <p>main.cpp:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;csvcontroller.h&gt;
  
  using namespace std;
  
  int main(){
  
      csvcontroller lista_logradouros;
      lista_logradouros.loadfile("C:\\Users\\d786282\\Desktop\\Base_JUN_V2\\20140828_base_jun_padronizada.csv",';');
      CsvLine* aux = lista_logradouros.getFirst();
      do{
          aux = aux-&gt;next;
      }while(aux != NULL);
  
  
  }
  </code></pre>
  
  <p>How can i debug / solve this?</p>