diff --git a/revision.c b/revision.c index 71e2337423..f6a1088381 100644 --- a/revision.c +++ b/revision.c @@ -1648,8 +1648,10 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg revs->skip_count = atoi(optarg); return argcount; } else if ((*arg == '-') && isdigit(arg[1])) { - /* accept -, like traditional "head" */ - revs->max_count = atoi(arg + 1); + /* accept -, like traditional "head" */ + if (strtol_i(arg + 1, 10, &revs->max_count) < 0 || + revs->max_count < 0) + die("'%s': not a non-negative integer", arg + 1); revs->no_walk = 0; } else if (!strcmp(arg, "-n")) { if (argc <= 1)