From: Phillip Wood Date: Wed, 12 Jun 2024 09:09:48 GMT Subject: Re: [PATCH v2 00/29] Memory leak fixes (pt.2) Message-ID: <7b62e733-0816-43be-a1b2-4d7d288ec6ee@gmail.com> In-Reply-To: Hi Patrick On 11/06/2024 10:19, Patrick Steinhardt wrote: > Hi, > > this is the second version of my patch series that fixes various memory > leaks in our codebase. > > 20: 48bcd0ac80 ! 20: 144eb23617 sequencer: fix leaking string buffer in `commit_staged_changes()` > @@ sequencer.c: static int commit_staged_changes(struct repository *r, > /* > * If a fixup/squash in a fixup/squash chain failed, the > @@ sequencer.c: static int commit_staged_changes(struct repository *r, > + * We need to update the squash message to skip > + * the latest commit message. > + */ > +- int res = 0; > + struct commit *commit; > + const char *msg; > const char *path = rebase_path_squash_msg(); > const char *encoding = get_commit_output_encoding(); > > @@ sequencer.c: static int commit_staged_changes(struct repository *r, > > p = repo_logmsg_reencode(r, commit, NULL, encoding); > if (!p) { > -@@ sequencer.c: static int commit_staged_changes(struct repository *r, > +- res = error(_("could not parse commit %s"), > ++ ret = error(_("could not parse commit %s"), > + oid_to_hex(&commit->object.oid)); > + goto unuse_commit_buffer; > + } > + find_commit_subject(p, &msg); > + if (write_message(msg, strlen(msg), path, 0)) { > +- res = error(_("could not write file: " > ++ ret = error(_("could not write file: " > + "'%s'"), path); > + goto unuse_commit_buffer; > } > ++ > ++ ret = 0; > ++ > unuse_commit_buffer: > repo_unuse_commit_buffer(r, commit, p); > - if (res) > - return res; > -+ if (res) { > -+ ret = res; > ++ if (ret) > + goto out; > -+ } > } > } This looks good, thanks for tweaking it Best Wishes Phillip