Show 50 quoted lines
> 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;
> -+ }
> }
> }