Skip to content

Commit

Permalink
Fix OOB access when computing -# tag for file without extension
Browse files Browse the repository at this point in the history
It is unlikely that this would ever come in practice, but there
is no reason to fix it.

Related to #2798
  • Loading branch information
horenmar committed Feb 10, 2024
1 parent 1078e7e commit 2a5de4e
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/catch2/catch_test_case_info.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 2a5de4e

Please sign in to comment.