From 643a6939ae94fdfc28ed848900852e05454b8d6a Mon Sep 17 00:00:00 2001 From: Alsey Coleman Miller Date: Mon, 27 Nov 2017 20:21:30 -0500 Subject: [PATCH] Added preconditions for HCI LE commands --- Sources/LowEnergyCommandParameter.swift | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Sources/LowEnergyCommandParameter.swift b/Sources/LowEnergyCommandParameter.swift index 03cc8803a..8ea2b98a3 100644 --- a/Sources/LowEnergyCommandParameter.swift +++ b/Sources/LowEnergyCommandParameter.swift @@ -26,6 +26,8 @@ public extension LowEnergyCommand { public init(data: LowEnergyAdvertisingData, length: UInt8) { + precondition(length <= 31, "LE Advertising Data can only be 31 octets") + self.length = length self.data = data } @@ -156,6 +158,8 @@ public extension LowEnergyCommand { public init(data: LowEnergyScanData, length: UInt8) { + precondition(length <= 31, "LE Scan Response Data can only be 31 octets") + self.length = length self.data = data }