Skip to content

Commit ed94a00

Browse files
gaalexandrekris-jusiak
authored andcommitted
Fix a segmentation fault caused by a negative argc
On some platforms the cmd_line_args function sets cfg::largc to -1 and trigger a segmentation fault in parse.
1 parent 3cfd993 commit ed94a00

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

include/boost/ut.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -803,7 +803,7 @@ struct cfg {
803803
}
804804

805805
static inline void parse(int argc, const char* argv[]) {
806-
const std::size_t n_args = static_cast<std::size_t>(argc);
806+
const std::size_t n_args = argc > 0 ? static_cast<std::size_t>(argc) : 0U;
807807
if (n_args > 0 && argv != nullptr) {
808808
cfg::largc = argc;
809809
cfg::largv = argv;

0 commit comments

Comments
 (0)