summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--win/inspircd_win32wrapper.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/win/inspircd_win32wrapper.cpp b/win/inspircd_win32wrapper.cpp
index bc68a2486..8291cd60d 100644
--- a/win/inspircd_win32wrapper.cpp
+++ b/win/inspircd_win32wrapper.cpp
@@ -652,6 +652,7 @@ int getcpu()
while (pEnumerator)
{
VARIANT vtProp;
+ VariantInit(&vtProp);
/* Next item */
HRESULT hr = pEnumerator->Next(WBEM_INFINITE, 1, &pclsObj, &uReturn);
@@ -664,9 +665,10 @@ int getcpu()
if (!FAILED(hr))
{
/* Matches our process ID? */
- if (vtProp.uintVal == GetCurrentProcessId())
- {
- VariantClear(&vtProp);
+ UINT pid = vtProp.uintVal;
+ VariantClear(&vtProp);
+ if (pid == GetCurrentProcessId())
+ {
/* Get CPU percentage for this process */
hr = pclsObj->Get(L"PercentProcessorTime", 0, &vtProp, 0, 0);
if (!FAILED(hr))
@@ -674,18 +676,19 @@ int getcpu()
/* Deal with wide string ickyness. Who in their right
* mind puts a number in a bstrVal wide string item?!
*/
- VariantClear(&vtProp);
cpu = 0;
std::wstringstream out(vtProp.bstrVal);
out >> cpu;
- break;
+ VariantClear(&vtProp);
}
+ pclsObj->Release();
+ break;
}
+ pclsObj->Release();
}
}
pEnumerator->Release();
- pclsObj->Release();
}
SysFreeString(Language);