Переглянути джерело

assert checked too early. Backport 18385d0. Fixes #288.

Marcin Krzyżanowski 9 роки тому
батько
коміт
2a31fbb2cf
1 змінених файлів з 2 додано та 1 видалено
  1. 2 1
      Sources/CryptoSwift/PKCS7.swift

+ 2 - 1
Sources/CryptoSwift/PKCS7.swift

@@ -37,11 +37,12 @@ public struct PKCS7: Padding {
     }
 
     public func remove(bytes: Array<UInt8>, blockSize:Int?) -> Array<UInt8> {
-        assert(!bytes.isEmpty, "Need bytes to remove padding")
         guard !bytes.isEmpty, let lastByte = bytes.last else {
             return bytes
         }
 
+        assert(!bytes.isEmpty, "Need bytes to remove padding")
+
         let padding = Int(lastByte) // last byte
         let finalLength = bytes.count - padding