Jeff King <peff@xxxxxxxx> writes: > On Wed, Mar 15, 2023 at 05:45:36PM +0000, Derrick Stolee via GitGitGadget wrote: > >> @@ -75,7 +79,21 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) >> ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase); >> filter.ignore_case = icase; >> >> - filter.name_patterns = argv; >> + if (from_stdin) { >> + struct strbuf line = STRBUF_INIT; >> + >> + if (argv[0]) >> + die(_("unknown arguments supplied with --stdin")); >> + >> + while (strbuf_getline(&line, stdin) != EOF) >> + strvec_push(&vec, line.buf); >> + >> + /* vec.v is NULL-terminated, just like 'argv'. */ >> + filter.name_patterns = vec.v; >> + } else { >> + filter.name_patterns = argv; >> + } > > Now that you aren't detaching the "line" strbuf in each iteration of the > loop, it needs to eventually be cleaned up. strbuf_getline() will > _reset() it, which is good, but at the end we'd need a strbuf_release() > or it will leak. Nicely spotted. Thanks.