title: Application freezes when freeing memory
body: <p>I have the following code where I try to convert the string <code>03080000</code> into a byte array with the first byte being 03, second being 08, third 00, and fourth 00.</p>
  
  <p>But it keeps freezing when i'm freeing the memory.<br>
  I tried stepping through it with a debugger (visual studio), but when I step over the free() function the debugger just seems to stop and it just hangs.</p>
  
  <p>Am I corrupting <code>bData</code> by the way I'm writing to it? Or what could be wrong?</p>
  
  <pre><code>LPCWSTR lpValueData = L"03080000"
  WCHAR HexChar[2] = {0};
  
  UINT i;
  UINT n = 0;
  
  DWORD dwDataSize;
  PBYTE bData;
  
  dwDataSize = wcslen(lpValueData) / 2;
  bData = (PBYTE) malloc(dwDataSize);
  for (i = 0; i &lt; dwDataSize * 2; i += 2)
  {
      HexChar[0] = lpValueData[i];
      HexChar[1] = lpValueData[i + 1];
  
      swscanf_s(HexChar, L"%X", &amp;bData[n++]);
  }
  // I want bData to be {0x03, 0x08, 0x00, 0x00}
  // Compare bData to another byte array here with memcmp
  free(bData); // freezes here.
  </code></pre>