aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/optparse/optparse.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/lib/optparse/optparse.c b/lib/optparse/optparse.c
index 6c05d64..407fa62 100644
--- a/lib/optparse/optparse.c
+++ b/lib/optparse/optparse.c
@@ -55,9 +55,10 @@ optparse(struct optparse *st, const struct op_option *opts, size_t nopts)
};
for (size_t i = 0; i < nopts; i++) {
- if (!u8haspfx(U8_ARGS(opts[i].longopt), U8_ARGS(opt_no_eq)))
+ struct u8view lo = opts[i].longopt;
+ if (lo.p == nullptr || !u8haspfx(U8_ARGS(lo), U8_ARGS(opt_no_eq)))
continue;
- if (o)
+ if (o != nullptr)
return error(st, OPT_MSG_INVALID, opt_no_eq);
o = opts + i;
}