]> granicus.if.org Git - graphviz/commit
fix file handle leakage
authorMatthew Fernandez <matthew.fernandez@gmail.com>
Sun, 13 Sep 2020 02:14:50 +0000 (19:14 -0700)
committerMatthew Fernandez <matthew.fernandez@gmail.com>
Sat, 19 Sep 2020 16:42:59 +0000 (09:42 -0700)
commit8b5a3a1c2fe3bb74d8c5ab686684e6728530a050
tree7d92493de7fe2a10be009fabd5c77a6f2270428c
parent8432ab9990a57d9e815db869c7ac756da78bb876
fix file handle leakage

This addresses the following Coverity warnings:

  Error: RESOURCE_LEAK (CWE-772): [#def30]
  graphviz-2.40.1/cmd/lefty/lefty.c:469: alloc_fn: Storage is returned from allocation function "fopen".
  graphviz-2.40.1/cmd/lefty/lefty.c:469: var_assign: Assigning: "fp" = storage returned from "fopen(argv[0], "r")".
  graphviz-2.40.1/cmd/lefty/lefty.c:464: overwrite_var: Overwriting "fp" in "fp = stdin" leaks the storage that "fp" points to.
  #  462|               usage(0);
  #  463|           else if (strcmp (argv[0], "-") == 0)
  #  464|->             fp = stdin;
  #  465|           else if (argv[0][0] == '-') {
  #  466|               fprintf (stderr, "option %s unrecognized - ignored\n", argv[0]);

  Error: RESOURCE_LEAK (CWE-772): [#def31]
  graphviz-2.40.1/cmd/lefty/lefty.c:469: alloc_fn: Storage is returned from allocation function "fopen".
  graphviz-2.40.1/cmd/lefty/lefty.c:469: var_assign: Assigning: "fp" = storage returned from "fopen(argv[0], "r")".
  graphviz-2.40.1/cmd/lefty/lefty.c:469: overwrite_var: Overwriting "fp" in "fp = fopen(argv[0], "r")" leaks the storage that "fp" points to.
  #  467|           }
  #  468|           else {
  #  469|->             if ((fp = fopen (argv[0], "r")) == NULL) {
  #  470|                   fprintf (stderr, "cannot open input file: %s\n", argv[0]);
  #  471|                   exit(2);

Related to #1464.
cmd/lefty/lefty.c