diff options
author | Junio C Hamano <gitster@pobox.com> | 2016-05-23 14:54:37 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2016-05-23 14:54:38 -0700 |
commit | ec34a8b135182ed41786cd87295d7086283dee64 (patch) | |
tree | 76ee81a33f3ab2ec9791c90e79ac161dd18fe48e /rerere.c | |
parent | f895dd7422766f8ce95433619510e957e54f60cd (diff) | |
parent | d9d501b0683f47f0150ea5c545426f9474cdd350 (diff) | |
download | git-ec34a8b135182ed41786cd87295d7086283dee64.tar.gz |
Merge branch 'jc/rerere-multi'
* jc/rerere-multi:
rerere: remove an null statement
rerere: plug memory leaks upon "rerere forget" failure
Diffstat (limited to 'rerere.c')
-rw-r--r-- | rerere.c | 25 |
1 files changed, 17 insertions, 8 deletions
@@ -1050,8 +1050,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); - 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); @@ -1060,14 +1060,19 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) 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"); - if (unlink(filename)) - return (errno == ENOENT - ? error("no remembered resolution for %s", path) - : error_errno("cannot unlink %s", filename)); + if (unlink(filename)) { + if (errno == ENOENT) + error("no remembered resolution for %s", path); + else + error_errno("cannot unlink %s", filename); + goto fail_exit; + } /* * Update the preimage so that the user can resolve the @@ -1086,6 +1091,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; + +fail_exit: + free(id); + return -1; } int rerere_forget(struct pathspec *pathspec) |