summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--parse-options-cb.c3
-rw-r--r--parse-options.c3
2 files changed, 6 insertions, 0 deletions
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 2733393546..02293493b0 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -16,6 +16,9 @@ int parse_opt_abbrev_cb(const struct option *opt, const char *arg, int unset)
if (!arg) {
v = unset ? 0 : DEFAULT_ABBREV;
} else {
+ if (!*arg)
+ return error(_("option `%s' expects a numerical value"),
+ opt->long_name);
v = strtol(arg, (char **)&arg, 10);
if (*arg)
return error(_("option `%s' expects a numerical value"),
diff --git a/parse-options.c b/parse-options.c
index cec74522e5..c8ee221196 100644
--- a/parse-options.c
+++ b/parse-options.c
@@ -193,6 +193,9 @@ static enum parse_opt_result get_value(struct parse_opt_ctx_t *p,
}
if (get_arg(p, opt, flags, &arg))
return -1;
+ if (!*arg)
+ return error(_("%s expects a numerical value"),
+ optname(opt, flags));
*(int *)opt->value = strtol(arg, (char **)&s, 10);
if (*s)
return error(_("%s expects a numerical value"),