bisect--helper: verify HEAD could be parsed before continuing
In 06f5608c14e6 (bisect--helper: `bisect_start` shell function partially in C, 2019-01-02), we introduced a call to `get_oid()` and did not check whether it succeeded before using its output. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Johannes Schindelin committed
May 21, 2019 at 10:50 UTC
7877ac3d7b8ae84981c9c2fa86a4f3701ade4510
1 file changed
+4
-1
builtin/bisect--helper.c
+4
-1
@@ -570,7 +570,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
570
write_file(git_path_bisect_start(), "%s\n", start_head.buf);
571
572
if (no_checkout) {
573
- get_oid(start_head.buf, &oid);
573
+ if (get_oid(start_head.buf, &oid) < 0) {
574
+ retval = error(_("invalid ref: '%s'"), start_head.buf);
575
+ goto finish;
576
+ }
577
if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
578
UPDATE_REFS_MSG_ON_ERR)) {
579
retval = -1;