Skip to content

Commit

Permalink
Fix a segmentation fault caused by a negative argc
Browse files Browse the repository at this point in the history
On some platforms the cmd_line_args function sets cfg::largc to -1 and
trigger a segmentation fault in parse.
  • Loading branch information
gaalexandre authored and krzysztof-jusiak committed May 15, 2024
1 parent 3cfd993 commit ed94a00
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion include/boost/ut.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -803,7 +803,7 @@ struct cfg {
}

static inline void parse(int argc, const char* argv[]) {
const std::size_t n_args = static_cast<std::size_t>(argc);
const std::size_t n_args = argc > 0 ? static_cast<std::size_t>(argc) : 0U;
if (n_args > 0 && argv != nullptr) {
cfg::largc = argc;
cfg::largv = argv;
Expand Down

0 comments on commit ed94a00

Please sign in to comment.