title: what is the problem for Heap corruption at the end of programin in this C++ program?
body: <p>There is a problem in my simple program about heap corruption I unfortunately could not understand. this error happens when program ends</p>
  
  <p>program is about reading a binary of specific length and split it to sub-packet then initialize a proper parser for each sub-packet and save all of parser in a deque </p>
  
  <blockquote>
    <p>HEAP CORRUPTION DETECTED: after Normal block (#182) at 0x005F2270. CRT
    detected that the application wrote to memory after end of heap
    buffer.</p>
  </blockquote>
  
  <pre><code>int main()
      {
          deque&lt;uint8_t&gt; testData = { 0, 115, 0, 0, 1, 1, 0, 0, 0, 0, 0, 100 };
          deque &lt; shared_ptr&lt;IParser&gt;&gt; parsers;
          Splitter test(testData, parsers);
          test.split();
      }
  </code></pre>
  
  <p>the Splitter class</p>
  
  <pre><code>struct Splitter {
      const deque&lt;uint8_t&gt;&amp; input;
      deque&lt;shared_ptr&lt;IParser&gt;&gt;&amp; parsers;
      long x = 0;
      Splitter(const deque&lt;uint8_t&gt;&amp; input, deque&lt;shared_ptr&lt;IParser&gt;&gt;&amp; parsers) :input(input), parsers(parsers)
      {
  
      }
  
      deque&lt;shared_ptr&lt;IParser&gt;&gt; getParsers();
      bool split() {
          deque&lt;uint8_t&gt; newVec;
          auto headerparser = make_shared&lt;HeaderParser&gt;(newVec);
          parsers.push_back(headerparser);
          return true;
      }
  
  };
  </code></pre>
  
  <p>the IParser class</p>
  
  <pre><code>struct IParser {
          const std::deque&lt;uint8_t&gt; input;
          IParser(const std::deque&lt;uint8_t&gt; input):input(input){} 
      };
  </code></pre>
  
  <p>and finally HeaderParser</p>
  
  <pre><code>struct HeaderParser :public IParser
  {
      shared_ptr&lt;Header&gt; output;
      HeaderParser(const deque&lt;uint8_t&gt;&amp; input):IParser(input)
      {
        uint8_t* buff = (uint8_t*)&amp;output;
        for (size_t i = 0; i &lt; sizeof(Header); i++)
           buff[i] = 0;
       }
  };
  </code></pre>