Fixed a leak in read-tree
[gitweb.git] / checkout-cache.c
index 244ebd122601883e15e8aefea33c7daf8249d862..b561ef487ee093207ba2034e1142614276d1e5a9 100644 (file)
@@ -48,6 +48,7 @@ static void create_directories(const char *path)
                buf[len] = 0;
                mkdir(buf, 0755);
        }
+       free(buf);
 }
 
 static int create_file(const char *path, unsigned int mode)
@@ -76,6 +77,8 @@ static int write_entry(struct cache_entry *ce, const char *path)
 
        new = read_sha1_file(ce->sha1, type, &size);
        if (!new || strcmp(type, "blob")) {
+               if (new)
+                       free(new);
                return error("checkout-cache: unable to read sha1 file of %s (%s)",
                        path, sha1_to_hex(ce->sha1));
        }