Commit 4cdff50
committed
Fix memory leaks and add resource cleanup in lsof_destroy
- Added sfile list cleanup in lsof_destroy() (aname, name, devnm fields)
- Added hashSfile hash buckets cleanup (HbyFdi, HbyFrd, HbyFsd, HbyNm)
- Added Lproc process array cleanup
- Added path allocation tracking in ck_file_arg() to free on error
- Added lsof_destroy() call before Exit() in main.c to ensure cleanup
- Reset counters after cleanup (HbyFdiCt, HbyFrdCt, HbyFsdCt, HbyNmCt, Hs, Nlproc, procs_cap)
These fixes address major memory leaks detected by AddressSanitizer when
running with file arguments that don't exist or when processing processes.1 parent 5c3045e commit 4cdff50
4 files changed
+44
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
767 | 767 | | |
768 | 768 | | |
769 | 769 | | |
| 770 | + | |
| 771 | + | |
| 772 | + | |
| 773 | + | |
| 774 | + | |
| 775 | + | |
| 776 | + | |
| 777 | + | |
| 778 | + | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
| 783 | + | |
| 784 | + | |
| 785 | + | |
| 786 | + | |
| 787 | + | |
| 788 | + | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
| 795 | + | |
| 796 | + | |
| 797 | + | |
| 798 | + | |
770 | 799 | | |
771 | 800 | | |
772 | 801 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
768 | 768 | | |
769 | 769 | | |
770 | 770 | | |
| 771 | + | |
771 | 772 | | |
772 | 773 | | |
773 | 774 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
121 | 121 | | |
122 | 122 | | |
123 | 123 | | |
| 124 | + | |
124 | 125 | | |
125 | 126 | | |
126 | 127 | | |
| |||
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
148 | | - | |
| 149 | + | |
149 | 150 | | |
150 | | - | |
| 151 | + | |
| 152 | + | |
151 | 153 | | |
152 | 154 | | |
153 | 155 | | |
154 | 156 | | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| |||
172 | 175 | | |
173 | 176 | | |
174 | 177 | | |
| 178 | + | |
175 | 179 | | |
176 | 180 | | |
177 | 181 | | |
| |||
267 | 271 | | |
268 | 272 | | |
269 | 273 | | |
| 274 | + | |
| 275 | + | |
270 | 276 | | |
271 | 277 | | |
272 | 278 | | |
| |||
561 | 567 | | |
562 | 568 | | |
563 | 569 | | |
564 | | - | |
565 | 570 | | |
566 | 571 | | |
567 | 572 | | |
| |||
2156 | 2161 | | |
2157 | 2162 | | |
2158 | 2163 | | |
2159 | | - | |
2160 | | - | |
2161 | | - | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
2162 | 2167 | | |
2163 | 2168 | | |
2164 | 2169 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1353 | 1353 | | |
1354 | 1354 | | |
1355 | 1355 | | |
1356 | | - | |
1357 | | - | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1358 | 1359 | | |
1359 | 1360 | | |
1360 | 1361 | | |
| |||
0 commit comments