From d05123066c92a0613ea2a286ae863d687c482a95 Mon Sep 17 00:00:00 2001 From: Michael Griebling Date: Mon, 27 Feb 2023 08:28:57 -0500 Subject: [PATCH] Fixed crash when sublist is nil. --- .../MathRender/MTMathListBuilder.swift | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/Sources/SwiftMath/MathRender/MTMathListBuilder.swift b/Sources/SwiftMath/MathRender/MTMathListBuilder.swift index ac3216b..e680fef 100644 --- a/Sources/SwiftMath/MathRender/MTMathListBuilder.swift +++ b/Sources/SwiftMath/MathRender/MTMathListBuilder.swift @@ -260,15 +260,16 @@ public struct MTMathListBuilder { spacesAllowed = command == "text" let oldFontStyle = currentFontStyle currentFontStyle = fontStyle - let sublist = self.buildInternal(true)! - // Restore the font style. - currentFontStyle = oldFontStyle - spacesAllowed = oldSpacesAllowed - - prevAtom = sublist.atoms.last - list.append(sublist) - if oneCharOnly { - return list + if let sublist = self.buildInternal(true) { + // Restore the font style. + currentFontStyle = oldFontStyle + spacesAllowed = oldSpacesAllowed + + prevAtom = sublist.atoms.last + list.append(sublist) + if oneCharOnly { + return list + } } continue }