diff options
| author | Martin Hořeňovský | 2024-02-08 22:10:39 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2024-02-10 23:27:19 +0100 |
| commit | 2a5de4e4476b7297e2f4e37b79ef9141a1829947 (patch) | |
| tree | e5d1dacfb92a84f542ad02d0dec472d885af9d33 /src | |
| parent | 1078e7e95b3a06d4dadc75188de48bc4afffb955 (diff) | |
| download | catch3-2a5de4e4476b7297e2f4e37b79ef9141a1829947.tar.gz | |
Fix OOB access when computing -# tag for file without extension
It is unlikely that this would ever come in practice, but there
is no reason to fix it.
Related to #2798
Diffstat (limited to 'src')
| -rw-r--r-- | src/catch2/catch_test_case_info.cpp | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/catch2/catch_test_case_info.cpp b/src/catch2/catch_test_case_info.cpp index c38ee55a..2a4fbd33 100644 --- a/src/catch2/catch_test_case_info.cpp +++ b/src/catch2/catch_test_case_info.cpp @@ -85,8 +85,10 @@ namespace Catch { while (lastDot > 0 && filename[lastDot - 1] != '.') { --lastDot; } - --lastDot; + // In theory we could have filename without any extension in it + if ( lastDot == 0 ) { return StringRef(); } + --lastDot; size_t nameStart = lastDot; while (nameStart > 0 && filename[nameStart - 1] != '/' && filename[nameStart - 1] != '\\') { --nameStart; |