From dab9b2832dd6a857628cdb7bb3a083cd06976a78 Mon Sep 17 00:00:00 2001 From: Ruslan Alikhamov Date: Mon, 11 Mar 2024 12:39:17 +0400 Subject: [PATCH] Fixed crash in AnnotationParser (#1297) --- .../Sources/Parsing/Utils/AnnotationsParser.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/SourceryFramework/Sources/Parsing/Utils/AnnotationsParser.swift b/SourceryFramework/Sources/Parsing/Utils/AnnotationsParser.swift index af25058b3..0dec0d896 100644 --- a/SourceryFramework/Sources/Parsing/Utils/AnnotationsParser.swift +++ b/SourceryFramework/Sources/Parsing/Utils/AnnotationsParser.swift @@ -180,6 +180,9 @@ public struct AnnotationsParser { let utf8View = sourceLine.content.utf8 var startIndex: String.UTF8View.Index var endIndex: String.UTF8View.Index + guard utf8View.count > position.character else { + return ("", sourceLine) + } if shouldUsePositionBeforeTrailing { startIndex = utf8View.index(utf8View.startIndex, offsetBy: (position.character - 1)) endIndex = utf8View.endIndex