title: *** glibc detected *** free(): invalid pointer:
body: <p>I'm completely stumped as to the cause of the above glibc error. I must be missing something obvious, but it appears every time the following program (consisting of 4 files) exits:</p>
  
  <p>TankSim.h:</p>
  
  <pre><code>#ifndef TANKSIM_WDECAY_TANKSIM_H_
  #define TANKSIM_WDECAY_TANKSIM_H_
  
  #include &lt;cstdlib&gt;
  #include &lt;iostream&gt;
  
  #include "Parser.h"
  
  int main();
  
  #endif
  </code></pre>
  
  <p>TankSim.cpp:</p>
  
  <pre><code>#include "TankSim.h"
  
  using std::cout;
  using std::endl;
  
  int main()
  {
       const Settings gGlobals = ParseConfig();
  
       return(0);
  }
  </code></pre>
  
  <p>Parser.h:</p>
  
  <pre><code>#ifndef TANKSIM_WDECAY_PARSER_H_
  #define TANKSIM_WDECAY_PARSER_H_
  
  #include &lt;cstdlib&gt;
  #include &lt;vector&gt;
  #include &lt;fstream&gt;
  #include &lt;sstream&gt;
  #include &lt;iostream&gt;
  
  struct Settings {
    double speedlight;
    double refractiveindex;
    double absorptionchance;
    double pmtradius;
    double photspermetre;
    double tankradius;
    double tankheight;
    long unsigned int randomseed;
    double scatterangle;
    std::vector&lt;double&gt; entrypoint;
    std::vector&lt;double&gt; entrydrn;
  };
  
  Settings ParseConfig();
  
  #endif
  </code></pre>
  
  <p>Parser.cpp:</p>
  
  <pre><code>#include "Parser.h"
  
  using std::string;
  using std::vector;
  using std::cout;
  using std::endl;
  
  Settings ParseConfig()
  {
    Settings settings;
  
    std::ifstream configfile("settings.dat");
  
    string line;
    while(getline(configfile,line)){
      //Comments start with %
      if(line.find("%") != string::npos){
        cout &lt;&lt; "Comment: " &lt;&lt; line &lt;&lt; endl;
        continue;
      }
  
      //Read in variable name.
      std::stringstream ss;
      ss &lt;&lt; line;
      string varname;
      ss &gt;&gt; varname;
      string value = line.substr(varname.length()+1);
      cout &lt;&lt; varname &lt;&lt; "-" &lt;&lt; value &lt;&lt; endl;
    }
  }
  </code></pre>
  
  <p>Since I'm not explicitly calling any delete operators, I have no idea why the error occurs.</p>