Преглед на файлове

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