Skip to content

Commit

Permalink
protection against program crashes, incorrect link to torrent.
Browse files Browse the repository at this point in the history
  • Loading branch information
leonsoft-kras committed Dec 3, 2018
1 parent f7a1c56 commit bdc2c17
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions main.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2581,7 +2581,14 @@ function TMainForm.DoAddTorrent(const FileName: Utf8String): boolean;
if IsProtocolSupported(FileName) then
torrent:='-'
else begin
fs:=TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyNone);
try
fs:=TFileStreamUTF8.Create(FileName, fmOpenRead or fmShareDenyNone); // why isnt in try
except
AppNormal; // if the clipboard garbage and file cant be created. just go out.
HideWaitMsg;
exit;
end;

try
SetLength(torrent, fs.Size);
fs.ReadBuffer(PChar(torrent)^, Length(torrent));
Expand Down Expand Up @@ -3238,7 +3245,7 @@ procedure TMainForm.acExportExecute(Sender: TObject); // PETROV
end;
end;

procedure TMainForm.acImportExecute(Sender: TObject); // PETROV
procedure TMainForm.acImportExecute(Sender: TObject);
var
s,d : string;
FileVar1: TextFile;
Expand Down Expand Up @@ -7890,7 +7897,7 @@ procedure TMainForm._onException(Sender: TObject; E: Exception);
else
system.Rewrite(f);

WriteLn(f,'');WriteLn(f,'crashed((');WriteLn(f,'');
WriteLn(f,'');WriteLn(f,'v.' + AppVersion + ' crashed((');WriteLn(f,'');
myDumpExceptionBackTrace(f);
system.close(f);
halt(0);
Expand Down

0 comments on commit bdc2c17

Please sign in to comment.