Fix crashes due to forced unwrapping
This commit is contained in:
@@ -289,8 +289,11 @@ public struct MTMathListBuilder {
|
|||||||
return list
|
return list
|
||||||
} else {
|
} else {
|
||||||
// Create a new table with the current list and a default env
|
// Create a new table with the current list and a default env
|
||||||
let table = self.buildTable(env: nil, firstList: list, isRow: false)
|
if let table = self.buildTable(env: nil, firstList: list, isRow: false) {
|
||||||
return MTMathList(atom: table!)
|
return MTMathList(atom: table)
|
||||||
|
} else {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else if spacesAllowed && char == " " {
|
} else if spacesAllowed && char == " " {
|
||||||
// If spaces are allowed then spaces do not need escaping with a \ before being used.
|
// If spaces are allowed then spaces do not need escaping with a \ before being used.
|
||||||
@@ -720,7 +723,7 @@ public struct MTMathListBuilder {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
if env! != currentEnv!.envName {
|
if env! != currentEnv!.envName {
|
||||||
let errorMessage = "Begin environment name \(currentEnv!.envName!) does not match end name: \(env!)"
|
let errorMessage = "Begin environment name \(currentEnv!.envName ?? "(none)") does not match end name: \(env!)"
|
||||||
self.setError(.invalidEnv, message:errorMessage)
|
self.setError(.invalidEnv, message:errorMessage)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -187,7 +187,9 @@ final class MTMathListBuilderTests: XCTestCase {
|
|||||||
("\\begin{displaylines} x & y \\end{displaylines}", .invalidNumColumns),
|
("\\begin{displaylines} x & y \\end{displaylines}", .invalidNumColumns),
|
||||||
("\\begin{eqalign} x \\end{eqalign}", .invalidNumColumns),
|
("\\begin{eqalign} x \\end{eqalign}", .invalidNumColumns),
|
||||||
("\\nolimits", .invalidLimits),
|
("\\nolimits", .invalidLimits),
|
||||||
("\\frac\\limits{1}{2}", .invalidLimits)
|
("\\frac\\limits{1}{2}", .invalidLimits),
|
||||||
|
("&\\begin", .characterNotFound),
|
||||||
|
("x & y \\\\ z & w \\end{matrix}", .invalidEnv)
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user