commit 19305070924df3384e8d0cc9d561b183ffd0bdef from: Omar Polo via: Thomas Adam date: Sat Aug 06 20:57:41 2022 UTC avoid allocating too many errors in cmd_info got_error_path uses get_custom_err to get a statically allocated error allocated on a buffer that's used a ring. This is nice and simple, but the drawback is that thees custom errors shouldn't be used "for too long" because they might get overwritten later. cmd_info is one offender: change it to store a "simple" error and later re-use it to construct the per-path error. OK and tweaks stsp@ commit - 5f202665e2b4cbf6f91639324020b3591df7ec6c commit + 19305070924df3384e8d0cc9d561b183ffd0bdef blob - 4719e5dbdd776ed4b252cda4a1e43672e360f591 blob + edbcc7342bcb01d006c2e0688e8f5674d0e891b7 --- got/got.c +++ got/got.c @@ -13095,8 +13095,7 @@ cmd_info(int argc, char *argv[]) * Assume this path will fail. This will be corrected * in print_path_info() in case the path does suceeed. */ - pe->data = (void *)got_error_path(pe->path, - GOT_ERR_BAD_PATH); + pe->data = (void *)got_error(GOT_ERR_BAD_PATH); } error = got_worktree_path_info(worktree, &paths, print_path_info, &paths, check_cancelled, NULL); @@ -13104,7 +13103,11 @@ cmd_info(int argc, char *argv[]) goto done; TAILQ_FOREACH(pe, &paths, entry) { if (pe->data != NULL) { - error = pe->data; /* bad path */ + const struct got_error *perr; + + perr = pe->data; + error = got_error_fmt(perr->code, "%s", + pe->path); break; } }