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
diff --git a/parse-options-cb.c b/parse-options-cb.c
index 1240a85..c2062ae 100644
--- a/parse-options-cb.c
+++ b/parse-options-cb.c
@@ -161,6 +161,7 @@
struct option *parse_options_dup(const struct option *o)
{
+ const struct option *orig = o;
struct option *opts;
int nr = 0;
@@ -170,7 +171,7 @@
}
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;