Error in `main': free(): invalid pointer (though no free or delete used)
<p>I have this simple code that i m trying to run in tutorialspoint.com</p>

<pre><code>#include &lt;iostream&gt;

using namespace std;

class Vehicle {
    string vehicleNo;
    string color;

    protected:
    string getVehicleNo()
    {
        return vehicleNo;
    }

    string setVehicleNo(string num)
    {
        vehicleNo = num;
    }

    string getColor()
    {
        return color;
    }

    string setColor(string someColor)
    {
        color = someColor;
    }
};

class Car: public Vehicle {
    private:
    int distance;

    public:
    void setDistance(int a)
    {
        distance = a;
    }

    int calculateFare(int)
    {
        return distance * 5;
    }

    void displayInformation()
    {
        cout &lt;&lt; distance &lt;&lt; endl; 
    }

    void useSetVehicleNo(string num)
    {
        setVehicleNo(num);
    }

    string useSetColor(string someColor)
    {
        setColor(someColor);
    }

    string useGetVehicleNo()
    {
        return getVehicleNo();
    }

    string useGetColor()
    {
        return getColor();
    }
};

int main()
{
   //string exit=n;
   string vehicleNo;
   string color;
   Car car;

   cout &lt;&lt; "Enter car number : " &lt;&lt; endl;
   cin &gt;&gt; vehicleNo;
   car.useSetVehicleNo(vehicleNo);

   cout &lt;&lt; "Enter car color : " &lt;&lt; endl;
   cin &gt;&gt; color;
   car.useSetColor(color);

   //vehicleNo = car.useGetColor();
   //color = car.useGetVehicleNo();

   //cout &lt;&lt; vehicleNo;
   //cout &lt;&lt; color;


   return 0;
}
</code></pre>

<p>Running this is giving me the following output</p>

<blockquote>
  <p>Enter car number :<br>
  1<br>
  Enter car color :<br>
  g                                                                     </p>
  
  <p><strong>* Error in `main': free(): invalid pointer: 0x00007ff3aa205ba8 *</strong><br>
  ======= Backtrace: =========                                                                                                         /lib64/libc.so.6(+0x7850e)[0x7ff3a969450e]<br>
  /lib64/libc.so.6(cfree+0x5b5)[0x7ff3a96a0165]<br>
  main[0x400e97]<br>
  main[0x400c79]<br>
  /lib64/libc.so.6(__libc_start_main+0xf0)[0x7ff3a963bfe0]<br>
  main[0x400ac9]                                                        </p>
  
  <p>======= Memory map: ========                                                                                                         00400000-00402000 r-xp 00000000 fd:11f 59330668<br>
  /home/cg/roo                                                t/main<br>
  00601000-00602000 r--p 00001000 fd:11f 59330668<br>
  /home/cg/roo                                                t/main<br>
  00602000-00603000 rw-p 00002000 fd:11f 59330668<br>
  /home/cg/roo                                                t/main<br>
  0140c000-0142d000 rw-p 00000000 00:00 0<br>
  [heap]<br>
  7ff3a961c000-7ff3a97d0000 r-xp 00000000 fd:11f 37749826<br>
  /usr/lib64/l<br>
  ibc-2.20.so<br>
  7ff3a97d0000-7ff3a99cf000 ---p 001b4000 fd:11f 37749826<br>
  /usr/lib64/l<br>
  ibc-2.20.so<br>
  7ff3a99cf000-7ff3a99d3000 r--p 001b3000 fd:11f 37749826<br>
  /usr/lib64/l<br>
  ibc-2.20.so<br>
  7ff3a99d3000-7ff3a99d5000 rw-p 001b7000 fd:11f 37749826<br>
  /usr/lib64/l<br>
  ibc-2.20.so<br>
  7ff3a99d5000-7ff3a99d9000 rw-p 00000000 00:00 0<br>
  7ff3a99d9000-7ff3a99ef000 r-xp 00000000 fd:11f 37749844<br>
  /usr/lib64/l<br>
  ibgcc_s-4.9.2-20141101.so.1             7ff3a99ef000-7ff3a9bee000 ---p
  00016000 fd:11f 37749844                  /usr/lib64/l<br>
  ibgcc_s-4.9.2-20141101.so.1<br>
  7ff3a9bee000-7ff3a9bef000 r--p 00015000 fd:11f 37749844<br>
  /usr/lib64/l<br>
  ibgcc_s-4.9.2-20141101.so.1<br>
  7ff3a9bef000-7ff3a9bf0000 rw-p 00016000 fd:11f 37749844<br>
  /usr/lib64/l<br>
  ibgcc_s-4.9.2-20141101.so.1<br>
  7ff3a9bf0000-7ff3a9cf7000 r-xp 00000000 fd:11f 37749280<br>
  /usr/lib64/l<br>
  ibm-2.20.so<br>
  7ff3a9cf7000-7ff3a9ef6000 ---p 00107000 fd:11f 37749280<br>
  /usr/lib64/l<br>
  ibm-2.20.so<br>
  7ff3a9ef6000-7ff3a9ef7000 r--p 00106000 fd:11f 37749280<br>
  /usr/lib64/l<br>
  ibm-2.20.so<br>
  7ff3a9ef7000-7ff3a9ef8000 rw-p 00107000 fd:11f 37749280<br>
  /usr/lib64/l<br>
  ibm-2.20.so<br>
  7ff3a9ef8000-7ff3a9fe8000 r-xp 00000000 fd:11f 37749829<br>
  /usr/lib64/l<br>
  ibstdc++.so.6.0.20<br>
  7ff3a9fe8000-7ff3aa1e8000 ---p 000f0000 fd:11f 37749829<br>
  /usr/lib64/l<br>
  ibstdc++.so.6.0.20<br>
  7ff3aa1e8000-7ff3aa1f0000 r--p 000f0000 fd:11f 37749829<br>
  /usr/lib64/l<br>
  ibstdc++.so.6.0.20<br>
  7ff3aa1f0000-7ff3aa1f2000 rw-p 000f8000 fd:11f 37749829<br>
  /usr/lib64/l<br>
  ibstdc++.so.6.0.20<br>
  7ff3aa1f2000-7ff3aa207000 rw-p 00000000 00:00 0<br>
  7ff3aa207000-7ff3aa228000 r-xp 00000000 fd:11f 37856921<br>
  /usr/lib64/l                                                d-2.20.so 
  7ff3aa412000-7ff3aa417000 rw-p 00000000 00:00 0<br>
  7ff3aa424000-7ff3aa428000 rw-p 00000000 00:00 0<br>
  7ff3aa428000-7ff3aa429000 r--p 00021000 fd:11f 37856921<br>
  /usr/lib64/l                                                d-2.20.so 
  7ff3aa429000-7ff3aa42a000 rw-p 00022000 fd:11f 37856921<br>
  /usr/lib64/l        7ff3aa429000-7ff3aa42a000 rw-p 00022000 fd:11f
  37856921                  /usr/lib64/l<br>
  d-2.20.so<br>
  7ff3aa42a000-7ff3aa42b000 rw-p 00000000 00:00 0<br>
  7fff1dddb000-7fff1ddfc000 rw-p 00000000 00:00 0<br>
  [stack]<br>
  7fff1ddfe000-7fff1de00000 r-xp 00000000 00:00 0<br>
  [vdso]<br>
  ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0<br>
  [vsyscall]                                                  Aborted
  (core dumped)</p>
</blockquote>