mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-04-05 04:18:31 +02:00
* IN case of IO error, MD5File will return an empty digest. Fixes issue #41194
This commit is contained in:
parent
bf510fbd62
commit
2256593e92
@ -630,17 +630,20 @@ begin
|
||||
Reset(F, 1);
|
||||
{$pop}
|
||||
|
||||
if IOResult = 0 then
|
||||
begin
|
||||
GetMem(Buf, BufSize);
|
||||
repeat
|
||||
BlockRead(F, Buf^, Bufsize, Count);
|
||||
if Count > 0 then
|
||||
MDUpdate(Context, Buf^, Count);
|
||||
until Count < BufSize;
|
||||
FreeMem(Buf, BufSize);
|
||||
Close(F);
|
||||
end;
|
||||
if IOResult <> 0 then
|
||||
begin
|
||||
Result:=Default(TMDDigest);
|
||||
Exit;
|
||||
end;
|
||||
|
||||
GetMem(Buf, BufSize);
|
||||
repeat
|
||||
BlockRead(F, Buf^, Bufsize, Count);
|
||||
if Count > 0 then
|
||||
MDUpdate(Context, Buf^, Count);
|
||||
until Count < BufSize;
|
||||
FreeMem(Buf, BufSize);
|
||||
Close(F);
|
||||
|
||||
MDFinal(Context, Result);
|
||||
FileMode := ofm;
|
||||
@ -663,17 +666,19 @@ begin
|
||||
Reset(F, 1);
|
||||
{$pop}
|
||||
|
||||
if IOResult = 0 then
|
||||
begin
|
||||
GetMem(Buf, BufSize);
|
||||
repeat
|
||||
BlockRead(F, Buf^, Bufsize, Count);
|
||||
if Count > 0 then
|
||||
MDUpdate(Context, Buf^, Count);
|
||||
until Count < BufSize;
|
||||
FreeMem(Buf, BufSize);
|
||||
Close(F);
|
||||
end;
|
||||
if IOResult <> 0 then
|
||||
begin
|
||||
Result:=Default(TMDDigest);
|
||||
Exit;
|
||||
end;
|
||||
GetMem(Buf, BufSize);
|
||||
repeat
|
||||
BlockRead(F, Buf^, Bufsize, Count);
|
||||
if Count > 0 then
|
||||
MDUpdate(Context, Buf^, Count);
|
||||
until Count < BufSize;
|
||||
FreeMem(Buf, BufSize);
|
||||
Close(F);
|
||||
|
||||
MDFinal(Context, Result);
|
||||
FileMode := ofm;
|
||||
|
Loading…
Reference in New Issue
Block a user