#220 Memory leak during WMIProbe operations.

Version 5.10
closed-fixed
5
2013-04-20
2012-06-14
Miroslaw Zurek
No

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) {
collectedItems->push_back(item);
}
}
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.

Discussion

  • Miroslaw Zurek
    Miroslaw Zurek
    2012-06-14

    • assigned_to: nobody --> mirz
     
    • status: open --> closed-fixed
     
  • Fixed in r1636 and 1637.