bisect--helper: verify HEAD could be parsed before continuing
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Tue, 21 May 2019 17:50:21 +0000 (10:50 -0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 28 May 2019 17:51:01 +0000 (10:51 -0700)
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>
builtin/bisect--helper.c
index e7325fe37f6148fd1ccd6fc5842bbc8f5022c306..1fbe156e67a4c75694de7e606a21cf959dd19f51 100644 (file)
@@ -570,7 +570,10 @@ static int bisect_start(struct bisect_terms *terms, int no_checkout,
        write_file(git_path_bisect_start(), "%s\n", start_head.buf);
 
        if (no_checkout) {
-               get_oid(start_head.buf, &oid);
+               if (get_oid(start_head.buf, &oid) < 0) {
+                       retval = error(_("invalid ref: '%s'"), start_head.buf);
+                       goto finish;
+               }
                if (update_ref(NULL, "BISECT_HEAD", &oid, NULL, 0,
                               UPDATE_REFS_MSG_ON_ERR)) {
                        retval = -1;