фикс утечек

This commit is contained in:
PC1\PTyTb 2025-08-08 19:11:31 +03:00
parent 71cdcc9909
commit 04b5259737
1 changed files with 76 additions and 85 deletions

View File

@ -199,7 +199,6 @@ procedure TTTW_Bot.ReadDB;
KeyLen, KeyIndex: integer;
B: Byte;
begin
// Преобразуем ключ в байты с использованием ANSI кодировки
KeyBytes := TEncoding.ANSI.GetBytes(Key);
KeyLen := Length(KeyBytes);
if KeyLen = 0 then
@ -210,7 +209,6 @@ procedure TTTW_Bot.ReadDB;
MemStream := TMemoryStream.Create;
try
KeyIndex := 0;
// Расшифровываем данные и записываем в поток в памяти
while InStream.Position < InStream.Size do
begin
InStream.ReadBuffer(B, 1);
@ -218,15 +216,12 @@ procedure TTTW_Bot.ReadDB;
MemStream.WriteBuffer(B, 1);
KeyIndex := (KeyIndex + 1) mod KeyLen;
end;
// Преобразуем данные из потока в TStrings
MemStream.Position := 0; // Сбрасываем позицию для чтения
MemStream.Position := 0;
Result := TStringList.Create;
try
// Используем ANSI кодировку для преобразования байтов в строку
Result.LoadFromStream(MemStream, TEncoding.ANSI);
except
// В случае ошибки освобождаем ресурсы и пробрасываем исключение
Result.Free;
Result.Free; // Îñâîáîæäàåì ïðè îøèáêå çàãðóçêè
raise;
end;
finally
@ -236,7 +231,6 @@ procedure TTTW_Bot.ReadDB;
InStream.Free;
end;
end;
// Çàãðóçêà êîìïîíåíòîâ íàñòðîåê (TEdit, TCheckBox)
procedure LoadSettingsComponents;
var
@ -276,25 +270,23 @@ procedure TTTW_Bot.ReadDB;
// Çàãðóçêà çàøèôðîâàííîãî êîíôèãà
procedure LoadEncryptedConfig;
var
sl: TStringList;
tempList: TStrings; // Âðåìåííûé ñïèñîê äëÿ ðåçóëüòàòà
I: integer;
begin
if not FileExists(myConst.cfg1) then
Exit;
sl := TStringList.Create;
tempList := nil; // Èíèöèàëèçàöèÿ
try
sl.Assign(XorDecryptToStrings(myConst.cfg1, 'fgvasrgEFAXFAFAS'));
for I := 0 to sl.Count - 1 do
tempList := XorDecryptToStrings(myConst.cfg1, 'fgvasrgEFAXFAFAS');
for I := 0 to tempList.Count - 1 do
begin
var
eqPos := Pos('=', sl[I]);
var eqPos := Pos('=', tempList[I]);
if eqPos > 0 then
begin
var
Key := Trim(Copy(sl[I], 1, eqPos - 1));
var
Value := Trim(Copy(sl[I], eqPos + 1, MaxInt));
var Key := Trim(Copy(tempList[I], 1, eqPos - 1));
var Value := Trim(Copy(tempList[I], eqPos + 1, MaxInt));
if Key = 'k1' then
appconst.TTV_ClientID := Value
@ -322,10 +314,9 @@ procedure TTTW_Bot.ReadDB;
frSettings1.btnGetDADef.Visible := (appconst.DA_ClientID <> '') and
(appconst.DA_Sicret <> '') and (appconst.DA_URL <> '');
finally
sl.Free;
tempList.Free; // Âàæíî: îñâîáîæäàåì âðåìåííûé ñïèñîê!
end;
end;
// Çàãðóçêà íàñòðîåê óâåäîìëåíèé
procedure LoadNotifySettings;
var