FIX: Viewer - crash with unreadable file

This commit is contained in:
Alexander Koblov 2025-03-30 01:59:54 +03:00
commit e701968cd1

View file

@ -1614,6 +1614,11 @@ function TViewerControl.MapFile(const sFileName: String): Boolean;
begin
FMappedFile := GetMem(FFileSize);
Result := (FileRead(FFileHandle, FMappedFile^, FFileSize) = FFileSize);
if not Result then
begin
FLastError := mbSysErrorMessage;
FreeMemAndNil(FMappedFile);
end;
FileClose(FFileHandle);
FFileHandle := 0;
end;