title: ERROR_INSUFFICIENT_BUFFER returned from GetAdaptersAddresses
body: <p>Using the following code, more or less copy-pasted from the <a href="http://msdn.microsoft.com/library/windows/desktop/aa365915%28v=vs.85%29.aspx" rel="nofollow">MSDN example of 
  GetAdaptersAddresses</a>, I get the return value 122, which means ERROR_INSUFFICIENT_BUFFER (according to <a href="http://msdn.microsoft.com/library/windows/desktop/ms681382%28v=vs.85%29.aspx" rel="nofollow">this system error code list</a>).</p>
  
  <pre><code>ULONG outBufLen = 150000;   // Tried for different (large) values here...
  PIP_ADAPTER_ADDRESSES pAddresses = (IP_ADAPTER_ADDRESSES *) malloc(outBufLen);
  DWORD dwRetVal = GetAdaptersAddresses(AF_INET, 0, NULL, pAddresses, &amp;outBufLen);
  // ....
  free(pAddresses);
  </code></pre>
  
  <p>The documentation of GetAdaptersAddresses does not list ERROR_INSUFFICIENT_BUFFER as one of the expected return values. (It lists ERROR_BUFFER_OVERFLOW, which should adjust outBufLen to the needed value, but that remains unchanged).</p>
  
  <p>Using GetAdaptersInfo instead leads to the same symptoms.</p>
  
  <p>This error does not occur on my development machine, but on one virtual and one real clean Windows 7 x86 SP1 installation (added the VC++ redistributables).</p>
  
  <p>As a c++ newbie, am I doing something wrong? What could cause this error and how to fix it? =)</p>