From: "René Scharfe" <l.s.r@web•de>
To: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail•com>,
git@vger•kernel.org
Cc: Siddharth Asthana <siddharthasthana31@gmail•com>
Subject: [PATCH] replay: move onto NULL check before first use
Date: Thu, 11 Dec 2025 18:56:54 +0100 [thread overview]
Message-ID: <9db2b913-b5d6-4617-b079-b4612eaa2b97@web.de> (raw)
In-Reply-To: <3d83161b-ec34-404a-bb0e-bf4da7ac1db5@app.fastmail.com>
cmd_replay() aborts if the pointer "onto" is NULL after argument
parsing, e.g. when specifying a non-existing commit with --onto.
15cd4ef1f4 (replay: make atomic ref updates the default behavior,
2025-11-06) added code that dereferences this pointer before the check.
Switch their places to avoid a segmentation fault.
Reported-by: Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail•com>
Signed-off-by: René Scharfe <l.s.r@web•de>
---
builtin/replay.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/replay.c b/builtin/replay.c
index 507b909df7..64ad2f0f04 100644
--- a/builtin/replay.c
+++ b/builtin/replay.c
@@ -454,6 +454,9 @@ int cmd_replay(int argc,
determine_replay_mode(repo, &revs.cmdline, onto_name, &advance_name,
&onto, &update_refs);
+ if (!onto) /* FIXME: Should handle replaying down to root commit */
+ die("Replaying down to root commit is not supported yet!");
+
/* Build reflog message */
if (advance_name_opt)
strbuf_addf(&reflog_msg, "replay --advance %s", advance_name_opt);
@@ -472,9 +475,6 @@ int cmd_replay(int argc,
}
}
- if (!onto) /* FIXME: Should handle replaying down to root commit */
- die("Replaying down to root commit is not supported yet!");
-
if (prepare_revision_walk(&revs) < 0) {
ret = error(_("error preparing revisions"));
goto cleanup;
--
2.52.0
next prev parent reply other threads:[~2025-12-11 17:57 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-11 16:34 [BUG] replay: segmentation fault when mistyping target to --onto Kristoffer Haugsbakk
2025-12-11 17:56 ` René Scharfe [this message]
2025-12-15 10:10 ` [PATCH] replay: move onto NULL check before first use Phillip Wood
2025-12-15 12:04 ` Kristoffer Haugsbakk
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=9db2b913-b5d6-4617-b079-b4612eaa2b97@web.de \
--to=l.s.r@web$(echo .)de \
--cc=git@vger$(echo .)kernel.org \
--cc=kristofferhaugsbakk@fastmail$(echo .)com \
--cc=siddharthasthana31@gmail$(echo .)com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox