@@ -495,9 +495,15 @@ static int get_terms(struct bisect_terms *terms)
495495 }
496496
497497 free_terms (terms );
498- strbuf_getline_lf (& str , fp );
498+ if (strbuf_getline_lf (& str , fp ) == EOF ) {
499+ res = -1 ;
500+ goto finish ;
501+ }
499502 terms -> term_bad = strbuf_detach (& str , NULL );
500- strbuf_getline_lf (& str , fp );
503+ if (strbuf_getline_lf (& str , fp ) == EOF ) {
504+ res = -1 ;
505+ goto finish ;
506+ }
501507 terms -> term_good = strbuf_detach (& str , NULL );
502508
503509finish :
@@ -1055,6 +1061,8 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
10551061 * word_end = '\0' ; /* NUL-terminate the word */
10561062
10571063 get_terms (terms );
1064+ if (!terms -> term_bad || !terms -> term_good )
1065+ return error (_ ("no terms defined" ));
10581066 if (check_and_set_terms (terms , p ))
10591067 return -1 ;
10601068
@@ -1381,6 +1389,8 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
13811389 return error (_ ("'%s' requires 0 arguments" ),
13821390 "git bisect next" );
13831391 get_terms (& terms );
1392+ if (!terms .term_bad || !terms .term_good )
1393+ return error (_ ("no terms defined" ));
13841394 res = bisect_next (& terms , prefix );
13851395 free_terms (& terms );
13861396 return res ;
@@ -1415,6 +1425,8 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
14151425
14161426 set_terms (& terms , "bad" , "good" );
14171427 get_terms (& terms );
1428+ if (!terms .term_bad || !terms .term_good )
1429+ return error (_ ("no terms defined" ));
14181430 res = bisect_skip (& terms , argc , argv );
14191431 free_terms (& terms );
14201432 return res ;
@@ -1427,6 +1439,8 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
14271439 struct bisect_terms terms = { 0 };
14281440
14291441 get_terms (& terms );
1442+ if (!terms .term_bad || !terms .term_good )
1443+ return error (_ ("no terms defined" ));
14301444 res = bisect_visualize (& terms , argc , argv );
14311445 free_terms (& terms );
14321446 return res ;
@@ -1441,6 +1455,8 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
14411455 if (!argc )
14421456 return error (_ ("'%s' failed: no command provided." ), "git bisect run" );
14431457 get_terms (& terms );
1458+ if (!terms .term_bad || !terms .term_good )
1459+ return error (_ ("no terms defined" ));
14441460 res = bisect_run (& terms , argc , argv );
14451461 free_terms (& terms );
14461462 return res ;
@@ -1480,6 +1496,8 @@ int cmd_bisect(int argc,
14801496
14811497 set_terms (& terms , "bad" , "good" );
14821498 get_terms (& terms );
1499+ if (!terms .term_bad || !terms .term_good )
1500+ return error (_ ("no terms defined" ));
14831501 if (check_and_set_terms (& terms , argv [0 ]) ||
14841502 !one_of (argv [0 ], terms .term_good , terms .term_bad , NULL ))
14851503 usage_msg_optf (_ ("unknown command: '%s'" ), git_bisect_usage ,
0 commit comments