Explorar o código

Skip loop when Length=0.

Length is unsigned, so "Length-1" will underflow to $FFFFFFFF.
Jordan Russell hai 1 ano
pai
achega
a7d5ed9d90
Modificáronse 1 ficheiros con 3 adicións e 0 borrados
  1. 3 0
      Components/ChaCha20.pas

+ 3 - 0
Components/ChaCha20.pas

@@ -129,6 +129,9 @@ procedure ChaCha20Crypt(var Context: TChaCha20Context; const InBuffer;
   end;
 
 begin
+  if Length = 0 then
+    Exit;
+
   var InBuf: PByte := @InBuffer;
   var OutBuf: PByte := @OutBuffer;
   var KeyStream: PByte := @Context.keystream;