Commit ec9ab85
Fix HANDLE_LEAK.EX in aulast.c
Close file handle 'f' before returning error in argument parsing
to prevent resource leak when --extract option is followed by
an invalid argument.
Svace report:
Handle 'f' is created at aulast.c:506 by calling function 'fopen'
and lost at aulast.c:506. (CWE404, CWE775)
This leaks happens in the end of main() and could be not fixed, but let's make static analyzers happy...
Example scaniors of leaks:
aulast --extract -f file -f file2
aulast -f file --extract --stdin
aulast --extract --user u1 --user u2
aulast --extract --tty t1 --tty t2
aulast --extract --invalid
Co-authored-by: Z.AI GLM-51 parent 828b5b2 commit ec9ab85
1 file changed
Lines changed: 10 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
497 | 497 | | |
498 | 498 | | |
499 | 499 | | |
500 | | - | |
| 500 | + | |
501 | 501 | | |
502 | 502 | | |
503 | 503 | | |
| |||
510 | 510 | | |
511 | 511 | | |
512 | 512 | | |
513 | | - | |
| 513 | + | |
514 | 514 | | |
515 | 515 | | |
516 | 516 | | |
517 | 517 | | |
518 | 518 | | |
519 | 519 | | |
520 | 520 | | |
521 | | - | |
| 521 | + | |
522 | 522 | | |
523 | 523 | | |
524 | 524 | | |
525 | 525 | | |
526 | 526 | | |
527 | 527 | | |
528 | 528 | | |
529 | | - | |
| 529 | + | |
530 | 530 | | |
531 | 531 | | |
532 | 532 | | |
533 | 533 | | |
534 | 534 | | |
535 | | - | |
| 535 | + | |
536 | 536 | | |
537 | 537 | | |
538 | 538 | | |
| |||
612 | 612 | | |
613 | 613 | | |
614 | 614 | | |
| 615 | + | |
| 616 | + | |
| 617 | + | |
| 618 | + | |
| 619 | + | |
615 | 620 | | |
616 | 621 | | |
617 | 622 | | |
| |||
0 commit comments