diff options
author | Thomas Voss <mail@thomasvoss.com> | 2024-04-27 20:49:23 +0200 |
---|---|---|
committer | Thomas Voss <mail@thomasvoss.com> | 2024-04-27 20:49:23 +0200 |
commit | e3e3dc622662f3e2cd0397b02ca1370d733ca226 (patch) | |
tree | 5dbb9cc268df589cb0fe6409f0da1daff89de0fd /lib | |
parent | bde49e2565fde8b4b82c8a740687ca43a6c00583 (diff) |
Properly check for nullptr
Diffstat (limited to 'lib')
-rw-r--r-- | lib/optparse/optparse.c | 5 |
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; } |