plug a memory leak in delete_blob()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
diff --git a/lib/worktree.c b/lib/worktree.c
index 1ad69b7..3ffa1b3 100644
--- a/lib/worktree.c
+++ b/lib/worktree.c
@@ -1450,33 +1450,32 @@ delete_blob(struct got_worktree *worktree, struct got_fileindex *fileindex,
err = get_file_status(&status, &sb, ie, ondisk_path, -1, NULL, repo);
if (err)
- return err;
+ goto done;
if (status == GOT_STATUS_MODIFY || status == GOT_STATUS_CONFLICT ||
status == GOT_STATUS_ADD) {
err = (*progress_cb)(progress_arg, GOT_STATUS_MERGE, ie->path);
if (err)
- return err;
+ goto done;
/*
* Preserve the working file and change the deleted blob's
* entry into a schedule-add entry.
*/
err = got_fileindex_entry_update(ie, ondisk_path, NULL, NULL,
0);
- if (err)
- return err;
} else {
err = (*progress_cb)(progress_arg, GOT_STATUS_DELETE, ie->path);
if (err)
- return err;
+ goto done;
if (status == GOT_STATUS_NO_CHANGE) {
err = remove_ondisk_file(worktree->root_path, ie->path);
if (err)
- return err;
+ goto done;
}
got_fileindex_entry_remove(fileindex, ie);
}
-
+done:
+ free(ondisk_path);
return err;
}