Commit 406ca29e authored by Junio C Hamano's avatar Junio C Hamano

Merge branch 'rs/parse-options-dup-null-fix'

Code cleanup.

* rs/parse-options-dup-null-fix:
  parse-options: avoid arithmetic on pointer that's potentially NULL
parents fce9e836 169bed74
......@@ -161,6 +161,7 @@ int parse_opt_tertiary(const struct option *opt, const char *arg, int unset)
struct option *parse_options_dup(const struct option *o)
{
const struct option *orig = o;
struct option *opts;
int nr = 0;
......@@ -170,7 +171,7 @@ struct option *parse_options_dup(const struct option *o)
}
ALLOC_ARRAY(opts, nr + 1);
memcpy(opts, o - nr, sizeof(*o) * nr);
COPY_ARRAY(opts, orig, nr);
memset(opts + nr, 0, sizeof(*opts));
opts[nr].type = OPTION_END;
return opts;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment