浏览代码

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