Bug Summary

File:programs/Utilities/hdevio_scan/hdevio_scan.cc
Location:line 65, column 4
Description:Potential leak of memory pointed to by 'hdevio'

Annotated Source Code

1
2#include <unistd.h>
3#include <stdlib.h>
4#include <stdint.h>
5#include <time.h>
6
7#include <iostream>
8#include <string>
9#include <vector>
10#include <stack>
11#include <thread>
12using namespace std;
13
14
15#include <DAQ/HDEVIO.h>
16
17class WorkerThread;
18
19
20vector<string> filenames;
21
22
23
24//----------------
25// Usage
26//----------------
27void Usage(string mess="")
28{
29
30
31 if(mess != "") cout << endl << mess << endl << endl;
32
33 exit(0);
34}
35
36//----------------
37// ParseCommandLineArguments
38//----------------
39void ParseCommandLineArguments(int narg, char *argv[])
40{
41
42 if(narg<2) Usage("You must supply a filename!");
43
44 for(int i=1; i<narg; i++){
45
46 filenames.push_back(argv[i]);
47 }
48}
49
50//----------------
51// main
52//----------------
53int main(int narg, char *argv[])
54{
55
56 ParseCommandLineArguments(narg, argv);
57
58 // Loop over input files
59 for(uint32_t i=0; i<filenames.size(); i++){
1
Loop condition is true. Entering loop body
3
Loop condition is true. Entering loop body
5
Loop condition is true. Entering loop body
60 string &filename = filenames[i];
61 cout << "Processing file " << (i+1) << "/" << filenames.size() << " : " << filename << endl;
62
63 HDEVIO *hdevio = new HDEVIO(filename);
6
Memory is allocated
64 if(!hdevio->is_open){
2
Taking false branch
4
Taking false branch
7
Taking true branch
65 cout << hdevio->err_mess.str() << endl;
8
Potential leak of memory pointed to by 'hdevio'
66 continue;
67 }
68
69 time_t start_time = time(NULL__null);
70 hdevio->PrintFileSummary();
71 time_t end_time = time(NULL__null);
72
73 delete hdevio;
74
75 cout << (end_time - start_time) << " sec " << endl;
76 }
77
78 return 0;
79}
80
81