diff options
| author | Leitwolf11 | 2026-11-14 22:42:54 +0300 |
|---|---|---|
| committer | Leitwolf11 | 2026-11-14 22:42:54 +0300 |
| commit | e2905c736cf2e36965c071c21bc7911eb3c59a7b (patch) | |
| tree | 537504b761ed21b6fe821aebbbf9eab6b398d054 /tools/Versions.cpp | |
| parent | 2d21d2e0f9c6e0789e9c55d6cba611234dc61a60 (diff) | |
| download | catch3-fix/version-tool-semver.tar.gz | |
Refuse a next patch past the largest numberfix/version-tool-semver
NextPatch added one to the patch without a check, so a patch at
std::numeric_limits<unsigned>::max() wrapped to 0 and --next would have
moved the version back. It returns nothing there now; tests cover a
three- and a four-number version at the limit.
Claude-Session: https://claude.ai/code/session_01Ji7xZMYjc4zankoc7hGBE1
Diffstat (limited to 'tools/Versions.cpp')
| -rw-r--r-- | tools/Versions.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/Versions.cpp b/tools/Versions.cpp index acc0fb4e..d3ae03cf 100644 --- a/tools/Versions.cpp +++ b/tools/Versions.cpp @@ -4,6 +4,7 @@ #include <algorithm> #include <cctype> #include <charconv> +#include <limits> #include <utility> #include <vector> @@ -73,7 +74,10 @@ namespace Progmasoft::Catch3::Tools NextPatch(std::string_view current) { const auto numbers = Numbers(current, 4); - if (!numbers || numbers->size() < 3) + // A patch number at its largest has no next one; adding one would + // wrap around to 0 and move the version back. + if (!numbers || numbers->size() < 3 + || (*numbers)[2] == std::numeric_limits<unsigned>::max()) { return std::nullopt; } |