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