attr_file: fix resource leak

This commit is contained in:
Patrick Steinhardt 2016-02-09 11:11:38 +01:00
parent e262545753
commit 24b8ed2b3a

View File

@ -123,7 +123,7 @@ int git_attr_file__load(
break; break;
} }
case GIT_ATTR_FILE__FROM_FILE: { case GIT_ATTR_FILE__FROM_FILE: {
int fd; int fd = -1;
/* For open or read errors, pretend that we got ENOTFOUND. */ /* For open or read errors, pretend that we got ENOTFOUND. */
/* TODO: issue warning when warning API is available */ /* TODO: issue warning when warning API is available */
@ -133,7 +133,8 @@ int git_attr_file__load(
(fd = git_futils_open_ro(entry->fullpath)) < 0 || (fd = git_futils_open_ro(entry->fullpath)) < 0 ||
(error = git_futils_readbuffer_fd(&content, fd, (size_t)st.st_size)) < 0) (error = git_futils_readbuffer_fd(&content, fd, (size_t)st.st_size)) < 0)
nonexistent = true; nonexistent = true;
else
if (fd >= 0)
p_close(fd); p_close(fd);
break; break;