From e3e3dc622662f3e2cd0397b02ca1370d733ca226 Mon Sep 17 00:00:00 2001 From: Thomas Voss Date: Sat, 27 Apr 2024 20:49:23 +0200 Subject: Properly check for nullptr --- lib/optparse/optparse.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib') 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; } -- cgit v1.2.3