From 8df9a4d2716ebf1c68eced0b6d9de185c6cfd50a Mon Sep 17 00:00:00 2001 From: HanaKami <94033416+hana-kami@users.noreply.github.com> Date: Fri, 19 Sep 2025 05:28:21 +0800 Subject: [PATCH] Fixes potential segmentation fault in edge cases. (#465) The options are parsed starting from 1, so check `current < argc` instead of `!=` in the case that `argc` is zero. --- include/cxxopts.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/cxxopts.hpp b/include/cxxopts.hpp index b969dc2..a5c67f1 100644 --- a/include/cxxopts.hpp +++ b/include/cxxopts.hpp @@ -2519,7 +2519,7 @@ OptionParser::parse(int argc, const char* const* argv) std::vector unmatched; - while (current != argc) + while (current < argc) { if (strcmp(argv[current], "--") == 0) {