From ed94a009c9a87bc0f3d01eafb5ad9a4c35b95311 Mon Sep 17 00:00:00 2001 From: alexandre Date: Wed, 15 May 2024 12:59:35 +0200 Subject: [PATCH] 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. --- include/boost/ut.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/boost/ut.hpp b/include/boost/ut.hpp index b0e59ed9..490ff612 100644 --- a/include/boost/ut.hpp +++ b/include/boost/ut.hpp @@ -803,7 +803,7 @@ struct cfg { } static inline void parse(int argc, const char* argv[]) { - const std::size_t n_args = static_cast(argc); + const std::size_t n_args = argc > 0 ? static_cast(argc) : 0U; if (n_args > 0 && argv != nullptr) { cfg::largc = argc; cfg::largv = argv;