Commit Diff


commit - 0b5cc0d6bd15581b0ff9e234d342f193c9947e0a
commit + c42269f62b72261f39abf4335fc61d795ddb4402
blob - b9e80b6b8b3840af153935f792463bd4507b225a
blob + 7e7c1b8b06d6bb7244ad69ed310e6bcb5609147c
--- lib/worktree.c
+++ lib/worktree.c
@@ -2241,7 +2241,7 @@ collect_commitables(void *arg, unsigned char status, c
 
 	err = got_path_dirname(&parent_path, path);
 	if (err)
-		goto done;
+		return err;
 
 	ct = malloc(sizeof(*ct));
 	if (ct == NULL) {
@@ -2262,7 +2262,7 @@ collect_commitables(void *arg, unsigned char status, c
 	}
 	err = got_pathlist_insert(&new, a->paths, ct->path, ct);
 done:
-	if (err || new == NULL)
+	if (ct && (err || new == NULL))
 		free_commitable(ct);
 	free(parent_path);
 	return err;