Commit 783993101949040865ea933eb73e35df806249b0

Carlos Martín Nieto 2014-04-21T16:38:52

attrcache: fix use-after-free Reported by coverity.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
diff --git a/src/attrcache.c b/src/attrcache.c
index 88b68eb..a750154 100644
--- a/src/attrcache.c
+++ b/src/attrcache.c
@@ -229,8 +229,8 @@ int git_attr_cache__get(
 	if (error < 0) {
 		/* remove existing entry */
 		if (file) {
-			git_attr_file__free(file); /* offset incref from lookup */
 			attr_cache_remove(cache, file);
+			git_attr_file__free(file); /* offset incref from lookup */
 			file = NULL;
 		}
 		/* no error if file simply doesn't exist */