Commit 1dbb600
Don't crash on "gemc help" with no topic
The early help handler read argv[i + 1] without a bounds check. For the
bare "gemc help" (the natural way to ask for the help index), i + 1 ==
argc, so argv[argc] (the null terminator) was passed to the std::string
parameter of printOptionOrSwitchHelp, throwing std::logic_error and
aborting. Bounds-check i + 1 < argc and fall back to printHelp() (which
already exists and exits) when no topic follows.
Verified: "gemc help" now prints the help index and exits 0 instead of
terminating with an uncaught exception (Geant4 11.4.1 dev container).
Fixes #121
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>1 parent 48f83e5 commit 1dbb600
1 file changed
Lines changed: 3 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
100 | 100 | | |
101 | 101 | | |
102 | 102 | | |
103 | | - | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
104 | 106 | | |
105 | 107 | | |
106 | 108 | | |
| |||
0 commit comments