title: Segmentation Fault || Access Violation Writing location
body: <p>I want to insert a Node in a doubly linked list. I'm passed in the position, the new coefficient of the Polynomial and its power. I have no compile errors, but I get a Segmentation fault in linux (g++) and an Access Violation Writing Location when I run it with Visual Studio. </p>
  
  <p>Unhandled exception at 0x00bd20ba in Program.exe: 0xC0000005: Access violation writing location 0xcdcdcdd9.</p>
  
  <pre><code>void Polynomial::insert( Term *pos, double newCoefficient, int power )
  {
      Term *newTerm = new Term; // create a new node to insert
  
      // Link the new node to previous and next, given the position
      newTerm-&gt;prev = pos-&gt;prev;
      newTerm-&gt;next = pos;
      newTerm-&gt;prev-&gt;next = newTerm; // Here's where I'm getting the error
      newTerm-&gt;next-&gt;prev = newTerm;
  
      // change the coefficient and power
      newTerm-&gt;coefficient = newCoefficient;
      newTerm-&gt;power = power;
  }
  </code></pre>
  
  <p>What am I doing wrong and How do I fix this?</p>