title: Error while downloading to memory using curl
body: <p>I want to download a file to memory using curl.<br>
  I am currently using <a href="https://curl.haxx.se/libcurl/c/getinmemory.html" rel="nofollow noreferrer">this</a> and it looks like it works to a certain extent but corrupts my file.<br>
  I have used sigbench and it is around 20% different (while comparing original and downloaded)<br><br>
  <a href="https://i.stack.imgur.com/wUdWF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wUdWF.png" alt="enter image description here"></a></p>
  
  <p>The file I want to download is a binary so it won't work after it's modified.<br>
  I am currently testing with the x86 version of <a href="https://github.com/carterjones/hello-world-dll" rel="nofollow noreferrer">this</a>.
  <a href="https://cdn.otaku.ooo/8au89.dll" rel="nofollow noreferrer">original binary</a>
  <a href="https://cdn.otaku.ooo/nfee3.dll" rel="nofollow noreferrer">downloaded binary</a><br>
  This is the code I am using to write it to a file:<br>
  <code>ofstream stream = ofstream("test.dll");
  stream.write(chunk.memory, chunk.size);</code> </p>