api: free beginning of heap object

Signed-off-by: Jason A. Donenfeld <Jason@zx2c4.com>
This commit is contained in:
Jason A. Donenfeld 2020-11-02 23:21:16 +01:00
parent ddacb5491a
commit 0d7b9c7319

View File

@ -282,16 +282,16 @@ DisableAllOurAdapters(_In_ HDEVINFO DevInfo, _Inout_ SP_DEVINFO_DATA_LIST **Disa
HeapFree(ModuleHeap, 0, DeviceNode); HeapFree(ModuleHeap, 0, DeviceNode);
break; break;
} }
goto cleanupDeviceInfoData; goto cleanupDeviceNode;
} }
BOOL IsOurs; BOOL IsOurs;
if (IsOurAdapter(DevInfo, &DeviceNode->Data, &IsOurs) != ERROR_SUCCESS || !IsOurs) if (IsOurAdapter(DevInfo, &DeviceNode->Data, &IsOurs) != ERROR_SUCCESS || !IsOurs)
goto cleanupDeviceInfoData; goto cleanupDeviceNode;
ULONG Status, ProblemCode; ULONG Status, ProblemCode;
if (CM_Get_DevNode_Status(&Status, &ProblemCode, DeviceNode->Data.DevInst, 0) != CR_SUCCESS || if (CM_Get_DevNode_Status(&Status, &ProblemCode, DeviceNode->Data.DevInst, 0) != CR_SUCCESS ||
((Status & DN_HAS_PROBLEM) && ProblemCode == CM_PROB_DISABLED)) ((Status & DN_HAS_PROBLEM) && ProblemCode == CM_PROB_DISABLED))
goto cleanupDeviceInfoData; goto cleanupDeviceNode;
LOG(WINTUN_LOG_INFO, L"Force closing all open handles for existing adapter"); LOG(WINTUN_LOG_INFO, L"Force closing all open handles for existing adapter");
if (ForceCloseWintunAdapterHandle(DevInfo, &DeviceNode->Data) != ERROR_SUCCESS) if (ForceCloseWintunAdapterHandle(DevInfo, &DeviceNode->Data) != ERROR_SUCCESS)
@ -303,15 +303,15 @@ DisableAllOurAdapters(_In_ HDEVINFO DevInfo, _Inout_ SP_DEVINFO_DATA_LIST **Disa
{ {
LOG_LAST_ERROR(L"Failed to disable existing adapter"); LOG_LAST_ERROR(L"Failed to disable existing adapter");
Result = Result != ERROR_SUCCESS ? Result : GetLastError(); Result = Result != ERROR_SUCCESS ? Result : GetLastError();
goto cleanupDeviceInfoData; goto cleanupDeviceNode;
} }
DeviceNode->Next = *DisabledAdapters; DeviceNode->Next = *DisabledAdapters;
*DisabledAdapters = DeviceNode; *DisabledAdapters = DeviceNode;
continue; continue;
cleanupDeviceInfoData: cleanupDeviceNode:
HeapFree(ModuleHeap, 0, &DeviceNode->Data); HeapFree(ModuleHeap, 0, DeviceNode);
} }
return Result; return Result;
} }