Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
rerere: plug memory leaks upon "rerere forget" failure
author
Junio C Hamano
<gitster@pobox.com>
Wed, 11 May 2016 23:19:17 +0000
(16:19 -0700)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 11 May 2016 23:25:32 +0000
(16:25 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
rerere.c
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (parent:
890fca8
)
diff --git
a/rerere.c
b/rerere.c
index 16938662dd4152f2d9bfaac31b9715209c3bbd51..a804171a4411d7a08427548a92ffe08ea98a2a33 100644
(file)
--- a/
rerere.c
+++ b/
rerere.c
@@
-1052,8
+1052,8
@@
static int rerere_forget_one_path(const char *path, struct string_list *rr)
handle_cache(path, sha1, rerere_path(id, "thisimage"));
if (read_mmfile(&cur, rerere_path(id, "thisimage"))) {
free(cur.ptr);
handle_cache(path, sha1, rerere_path(id, "thisimage"));
if (read_mmfile(&cur, rerere_path(id, "thisimage"))) {
free(cur.ptr);
- return error("Failed to update conflicted state in '%s'",
-
path)
;
+ error("Failed to update conflicted state in '%s'", path);
+
goto fail_exit
;
}
cleanly_resolved = !try_merge(id, path, &cur, &result);
free(result.ptr);
}
cleanly_resolved = !try_merge(id, path, &cur, &result);
free(result.ptr);
@@
-1062,14
+1062,19
@@
static int rerere_forget_one_path(const char *path, struct string_list *rr)
break;
}
break;
}
- if (id->collection->status_nr <= id->variant)
- return error("no remembered resolution for '%s'", path);
+ if (id->collection->status_nr <= id->variant) {
+ error("no remembered resolution for '%s'", path);
+ goto fail_exit;
+ }
filename = rerere_path(id, "postimage");
filename = rerere_path(id, "postimage");
- if (unlink(filename))
- return (errno == ENOENT
- ? error("no remembered resolution for %s", path)
- : error("cannot unlink %s: %s", filename, strerror(errno)));
+ if (unlink(filename)) {
+ if (errno == ENOENT)
+ error("no remembered resolution for %s", path);
+ else
+ error("cannot unlink %s: %s", filename, strerror(errno));
+ goto fail_exit;
+ };
/*
* Update the preimage so that the user can resolve the
/*
* Update the preimage so that the user can resolve the
@@
-1088,6
+1093,10
@@
static int rerere_forget_one_path(const char *path, struct string_list *rr)
item->util = id;
fprintf(stderr, "Forgot resolution for %s\n", path);
return 0;
item->util = id;
fprintf(stderr, "Forgot resolution for %s\n", path);
return 0;
+
+fail_exit:
+ free(id);
+ return -1;
}
int rerere_forget(struct pathspec *pathspec)
}
int rerere_forget(struct pathspec *pathspec)