From fd899c77f3cc452bb1d9f06ece71c7d954863caa Mon Sep 17 00:00:00 2001 From: Anton Marunko Date: Sun, 24 Nov 2019 15:03:03 +0600 Subject: [PATCH] Fix crash in parsing pattern --- Source/svg/SVGParser.swift | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/Source/svg/SVGParser.swift b/Source/svg/SVGParser.swift index 69a405f3..3b9577ae 100644 --- a/Source/svg/SVGParser.swift +++ b/Source/svg/SVGParser.swift @@ -465,16 +465,15 @@ open class SVGParser { if let units = element.allAttributes["patternContentUnits"]?.text, units == "objectBoundingBox" { contentUserSpace = false } - + var contentNode: Node? if pattern.children.isEmpty { if let parentPattern = parentPattern { contentNode = parentPattern.content } - } else if pattern.children.count == 1 { - if let shape = try parseNode(pattern.children.first!) as? Shape { - contentNode = shape - } + } else if pattern.children.count == 1, + let shape = try parseNode(pattern.children.first!) as? Shape { + contentNode = shape } else { var shapes = [Shape]() try pattern.children.forEach { indexer in @@ -484,7 +483,7 @@ open class SVGParser { } contentNode = Group(contents: shapes) } - + return UserSpacePattern(content: contentNode!, bounds: bounds, userSpace: userSpace,