summaryrefslogtreecommitdiff
path: root/server-info.c
diff options
context:
space:
mode:
Diffstat (limited to 'server-info.c')
-rw-r--r--server-info.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/server-info.c b/server-info.c
index 7bc4e75d22..5ec5b1d827 100644
--- a/server-info.c
+++ b/server-info.c
@@ -14,19 +14,21 @@ static int update_info_file(char *path, int (*generate)(FILE *))
char *tmp = mkpathdup("%s_XXXXXX", path);
int ret = -1;
int fd = -1;
- FILE *fp = NULL;
+ FILE *fp = NULL, *to_close;
safe_create_leading_directories(path);
fd = git_mkstemp_mode(tmp, 0666);
if (fd < 0)
goto out;
- fp = fdopen(fd, "w");
+ to_close = fp = fdopen(fd, "w");
if (!fp)
goto out;
+ fd = -1;
ret = generate(fp);
if (ret)
goto out;
- if (fclose(fp))
+ fp = NULL;
+ if (fclose(to_close))
goto out;
if (adjust_shared_perm(tmp) < 0)
goto out;
@@ -51,7 +53,7 @@ static int add_info_ref(const char *path, const struct object_id *oid,
int flag, void *cb_data)
{
FILE *fp = cb_data;
- struct object *o = parse_object(oid->hash);
+ struct object *o = parse_object(oid);
if (!o)
return -1;
@@ -131,7 +133,7 @@ static int read_pack_info_file(const char *infofile)
char line[1000];
int old_cnt = 0;
- fp = fopen(infofile, "r");
+ fp = fopen_or_warn(infofile, "r");
if (!fp)
return 1; /* nonexistent is not an error. */