From c35f9a395c69411f19cc855007327ba57d9e0805 Mon Sep 17 00:00:00 2001 From: Fabian Muecke Date: Fri, 15 Jul 2022 15:21:20 +0200 Subject: [PATCH] Fix infinite loop when parsing unknown parameter attribute (#300) --- Sources/MockingbirdGenerator/Parser/Models/Function.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/MockingbirdGenerator/Parser/Models/Function.swift b/Sources/MockingbirdGenerator/Parser/Models/Function.swift index 1ce45e94..81362ee9 100644 --- a/Sources/MockingbirdGenerator/Parser/Models/Function.swift +++ b/Sources/MockingbirdGenerator/Parser/Models/Function.swift @@ -97,7 +97,7 @@ struct Function: CustomStringConvertible, CustomDebugStringConvertible, Serializ mutableComponent = mutableComponent.dropFirst("@autoclosure".count) } else if mutableComponent.hasPrefix("@") { // Unknown parameter attribute. logWarning("Ignoring unknown parameter attribute \(String(mutableComponent).singleQuoted) in function type declaration \(String(serialized).singleQuoted)") - let index = mutableComponent.firstIndex(where: { !$0.isLetter && !$0.isNumber }) + let index = mutableComponent.dropFirst().firstIndex(where: { !$0.isLetter && !$0.isNumber }) ?? mutableComponent.endIndex mutableComponent = mutableComponent[index...] } else if mutableComponent == "inout" {