Read-only mirrors. Development, issues and pull requests are on GitHub.

summaryrefslogtreecommitdiffhomepage
path: root/src
diff options
context:
space:
mode:
authorMartin Hořeňovský2024-02-08 22:10:39 +0100
committerMartin Hořeňovský2024-02-10 23:27:19 +0100
commit2a5de4e4476b7297e2f4e37b79ef9141a1829947 (patch)
treee5d1dacfb92a84f542ad02d0dec472d885af9d33 /src
parent1078e7e95b3a06d4dadc75188de48bc4afffb955 (diff)
downloadcatch3-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.cpp4
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;