commit 3524bbf95aa21318b6fff23c10b26ac57d1ab374 from: Stefan Sperling date: Tue Oct 20 21:09:01 2020 UTC make merge_file() use got_path_dirname() instead of assuming const dirname(3) ok naddy commit - aedea96d3489c0ed29af9550743889f6660adc35 commit + 3524bbf95aa21318b6fff23c10b26ac57d1ab374 blob - 8495e38fc850e1447ba6876aca03ad9ea1676440 blob + c29ea7cbab4d1f121903653f3697db97180c3307 --- lib/worktree.c +++ lib/worktree.c @@ -782,18 +782,20 @@ merge_file(int *local_changes_subsumed, struct got_wor char *blob_orig_path = NULL; char *merged_path = NULL, *base_path = NULL; int overlapcnt = 0; - char *parent; + char *parent = NULL; char *symlink_path = NULL; FILE *symlinkf = NULL; *local_changes_subsumed = 0; - parent = dirname(ondisk_path); - if (parent == NULL) - return got_error_from_errno2("dirname", ondisk_path); + err = got_path_dirname(&parent, ondisk_path); + if (err) + return err; - if (asprintf(&base_path, "%s/got-merged", parent) == -1) - return got_error_from_errno("asprintf"); + if (asprintf(&base_path, "%s/got-merged", parent) == -1) { + err = got_error_from_errno("asprintf"); + goto done; + } err = got_opentemp_named_fd(&merged_path, &merged_fd, base_path); if (err) @@ -914,6 +916,7 @@ done: unlink(blob_orig_path); free(blob_orig_path); } + free(parent); return err; }