[windows] Fix stale pointer dereference. am: 95e21bc268 am: 1d08a291f5 am: e129a11372

Original change: https://android-review.googlesource.com/c/platform/external/openscreen/+/1982890

Change-Id: Ie5b655e3ec45cfa0015f420157225ec0123ddad0
diff --git a/platform/impl/network_interface_win.cc b/platform/impl/network_interface_win.cc
index f90d35d..c309545 100644
--- a/platform/impl/network_interface_win.cc
+++ b/platform/impl/network_interface_win.cc
@@ -16,7 +16,6 @@
     constexpr size_t INITIAL_BUFFER_SIZE = 15000;
     ULONG outbuflen = INITIAL_BUFFER_SIZE;
     std::vector<unsigned char> charbuf(INITIAL_BUFFER_SIZE);
-    PIP_ADAPTER_ADDRESSES paddrs = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(charbuf.data());
     DWORD ret = NO_ERROR;
     constexpr int MAX_RETRIES = 5;
 
@@ -25,7 +24,7 @@
         ret = GetAdaptersAddresses(AF_UNSPEC /* get both v4/v6 addrs */,
                                    GAA_FLAG_INCLUDE_PREFIX,
                                    NULL,
-                                   paddrs,
+                                   reinterpret_cast<IP_ADAPTER_ADDRESSES*>(charbuf.data()),
                                    &outbuflen);
         if (ret == ERROR_BUFFER_OVERFLOW) {
             charbuf.resize(outbuflen);
@@ -40,7 +39,7 @@
     }
 
     std::vector<InterfaceInfo> infos;
-    auto pcurraddrs = paddrs;
+    auto pcurraddrs = reinterpret_cast<IP_ADAPTER_ADDRESSES*>(charbuf.data());
     while (pcurraddrs != nullptr) {
         // TODO: return the interfaces
         OSP_DVLOG << "\tIfIndex=" << pcurraddrs->IfIndex;