memory leak in Compare::EventTree()

Issue #169 resolved
Jochem Snuverink created an issue

Coverity reports a memory leak in Compare::EventTree()

Code simplified:

  for (auto i = 0; i < t1->GetEntries(); i++)
    {
      ResultEvent* re = new ResultEvent();
      ...
      ret->eventResults.push_back(*re);
      ...
    }

re is copied in the push_back and leaked at the end of the loop.

An easy solution would be to make eventResults vector hold pointers, and delete them in the destructor of ResultEventTree. This avoids the copy and uses pointers in the container (generally advisable).

Comments (1)

  1. Log in to comment