diff --git a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift index 1acf0ef20..63daf0a4b 100644 --- a/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift +++ b/SignalServiceKit/src/Loki/API/Onion Requests/OnionRequestAPI.swift @@ -191,6 +191,7 @@ internal enum OnionRequestAPI { /// Returns a `Path` to be used for building an onion request. Builds new paths as needed. private static func getPath() -> Promise { + guard pathSize >= 1 else { preconditionFailure("Cannot build path of size zero.") } // randomElement() uses the system's default random generator, which is cryptographically secure if paths.count >= pathCount { return Promise { $0.fulfill(paths.randomElement()!) }