* IN case of IO error, MD5File will return an empty digest. Fixes issue #41194

This commit is contained in:
Michaël Van Canneyt 2025-03-16 19:14:55 +01:00
parent bf510fbd62
commit 2256593e92

View File

@ -630,8 +630,12 @@ begin
Reset(F, 1);
{$pop}
if IOResult = 0 then
if IOResult <> 0 then
begin
Result:=Default(TMDDigest);
Exit;
end;
GetMem(Buf, BufSize);
repeat
BlockRead(F, Buf^, Bufsize, Count);
@ -640,7 +644,6 @@ begin
until Count < BufSize;
FreeMem(Buf, BufSize);
Close(F);
end;
MDFinal(Context, Result);
FileMode := ofm;
@ -663,8 +666,11 @@ begin
Reset(F, 1);
{$pop}
if IOResult = 0 then
if IOResult <> 0 then
begin
Result:=Default(TMDDigest);
Exit;
end;
GetMem(Buf, BufSize);
repeat
BlockRead(F, Buf^, Bufsize, Count);
@ -673,7 +679,6 @@ begin
until Count < BufSize;
FreeMem(Buf, BufSize);
Close(F);
end;
MDFinal(Context, Result);
FileMode := ofm;