From 8d50c79c9163f13a62f08f2f6296e2ff99ab903d Mon Sep 17 00:00:00 2001 From: Michael Griebling Date: Mon, 27 Feb 2023 08:11:26 -0500 Subject: [PATCH] Fixed crash on invalid syntax in curly braces. --- Sources/SwiftMath/MathRender/MTMathListBuilder.swift | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Sources/SwiftMath/MathRender/MTMathListBuilder.swift b/Sources/SwiftMath/MathRender/MTMathListBuilder.swift index 69a117d..ac3216b 100644 --- a/Sources/SwiftMath/MathRender/MTMathListBuilder.swift +++ b/Sources/SwiftMath/MathRender/MTMathListBuilder.swift @@ -226,11 +226,12 @@ public struct MTMathListBuilder { continue } else if char == "{" { // this puts us in a recursive routine, and sets oneCharOnly to false and no stop character - let subList = self.buildInternal(false, stopChar: "}") - prevAtom = subList!.atoms.last - list.append(subList) - if oneCharOnly { - return list + if let subList = self.buildInternal(false, stopChar: "}") { + prevAtom = subList.atoms.last + list.append(subList) + if oneCharOnly { + return list + } } continue } else if char == "}" {