#220 Memory leak during WMIProbe operations.

Version 5.10

I found a memory leak during WMIProbe operations. Problem exists when an exception has occurred. There is a function:

ItemVector* WMIProbe::CollectItems(Object* object) {
ItemVector* collectedItems = new ItemVector();

// get all the namespaces
ItemEntityVector* namespaces = this->GetNamespaces(wmi_namespace);
ItemEntityVector::iterator namespaceIt;
for(namespaceIt=namespaces->begin(); namespaceIt!=namespaces->end(); namespaceIt++) {

// get all the wql queries
ItemEntityVector* wqls = this->GetWQLs(wmi_wql);
ItemEntityVector::iterator wqlIt;
for(wqlIt=wqls->begin(); wqlIt!=wqls->end(); wqlIt++) {

// run the wmi queries and push the results on the collectedItems
// return vector.
Item* item = this->GetWMI((*namespaceIt), (*wqlIt)); // <- sometimes I have an exception here.
if(item != NULL) {
delete wqls;
delete namespaces;

return collectedItems;

So when an exception exists in this function this->GetWMI((*namespaceIt), (*wqlIt)); following resources should be freed.

a) collectedItems
b) namespaces
c) wqls

but there isn't catch of exception on this level but it is on higher level. So it provides a memory leak.


  • Miroslaw Zurek

    Miroslaw Zurek - 2012-06-14
    • assigned_to: nobody --> mirz
  • Michael Chisholm

    • status: open --> closed-fixed
  • Michael Chisholm

    Fixed in r1636 and 1637.


Log in to post a comment.