Changeset cba6b9c


Ignore:
Timestamp:
Apr 23, 2014, 2:28:54 AM (3 years ago)
Author:
Anders Kaseorg <andersk@mit.edu>
Branches:
master
Children:
b61ad80
Parents:
9ae6095
git-author:
Anders Kaseorg <andersk@mit.edu> (04/23/14 02:27:51)
git-committer:
Anders Kaseorg <andersk@mit.edu> (04/23/14 02:28:54)
Message:
owl_util_file_deleteline: Prevent FD leak in error paths

Found by Coverity Scan service.

Signed-off-by: Anders Kaseorg <andersk@mit.edu>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    r7b89e8c rcba6b9c  
    468468  if (fstat(fileno(old), &st) != 0) {
    469469    owl_function_error("Cannot stat %s: %s", filename, strerror(errno));
     470    fclose(old);
    470471    return -1;
    471472  }
     
    473474  /* resolve symlinks, because link() fails on symlinks, at least on AFS */
    474475  actual_filename = owl_util_recursive_resolve_link(filename);
    475   if (actual_filename == NULL)
     476  if (actual_filename == NULL) {
     477    fclose(old);
    476478    return -1; /* resolving the symlink failed, but we already logged this error */
     479  }
    477480
    478481  newfile = g_strdup_printf("%s.new", actual_filename);
Note: See TracChangeset for help on using the changeset viewer.