summaryrefslogtreecommitdiff
path: root/src/attr.c
diff options
context:
space:
mode:
authorRussell Belfer <rb@github.com>2012-05-04 11:06:12 -0700
committerRussell Belfer <rb@github.com>2012-05-04 11:06:12 -0700
commitb709e95146b9d56e2c009915ccea7a86c77d4202 (patch)
treec9257b8278c8d1e28b0cfe5969317ef0ed63c315 /src/attr.c
parentf917481ee84cbba481c1854cccdedb2d98377d43 (diff)
downloadlibgit2-b709e95146b9d56e2c009915ccea7a86c77d4202.tar.gz
Fix memory leaks and use after free
Diffstat (limited to 'src/attr.c')
-rw-r--r--src/attr.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/attr.c b/src/attr.c
index 56d04d3a9..b7ac6355d 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -334,8 +334,6 @@ int git_attr_cache__push_file(
}
/* if not in cache, load data, parse, and cache */
- if (git_attr_file__new(&file, source, relfile, &cache->pool) < 0)
- return -1;
if (source == GIT_ATTR_FILE_FROM_FILE)
error = load_attr_file(filename, &content);
@@ -354,6 +352,9 @@ int git_attr_cache__push_file(
if (blob)
content = git_blob_rawcontent(blob);
+ if ((error = git_attr_file__new(&file, source, relfile, &cache->pool)) < 0)
+ goto finish;
+
if (parse && (error = parse(repo, content, file)) < 0)
goto finish;