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
This commit is contained in:
Martin Hořeňovský 2024-02-08 22:10:39 +01:00
parent 1078e7e95b
commit 2a5de4e447
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A

View File

@ -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;