Skip to content

Commit

Permalink
Fix the memory leak in main()
Browse files Browse the repository at this point in the history
  • Loading branch information
SoapZA committed May 30, 2021
1 parent 9649a77 commit a5c3b3d
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions src/toolkit/bamtools.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ int Help(int argc, char* argv[])

// if tool known, print its help screen
if (tool) {
return tool->Help();
const int result = tool->Help();
delete tool;
return result;
}
}

Expand Down Expand Up @@ -202,9 +204,10 @@ int main(int argc, char* argv[])
// determine desired sub-tool, run if found
AbstractTool* tool = CreateTool(argv[1]);
if (tool) {
return tool->Run(argc, argv);
const int result = tool->Run(argc, argv);
delete tool;
return result;
}
delete tool;

// no tool matched, show help
return Help(argc, argv);
Expand Down

0 comments on commit a5c3b3d

Please sign in to comment.