Delphi: 10.3 Version 26.0.36039.7899
This code generates a memory at the first call to SetLength:
A memory block has been leaked. The size is: 519
This block was allocated by thread 0x2010, and the stack trace (return addresses) at the time was:
00420A36 [FastMM5.pas][FastMM5][FastMM_DebugGetMem][7718]
006E43A7 [uMemory.pas][uMemory][NewAllocMem][88]
00407441 [System.pas][System][@ReallocMem][5022]
0040DB51 [System.pas][System][DynArraySetLength][36046]
0040B09C [System.pas][System][@LStrFromPWCharLen][26213]
0040DC92 [System.pas][System][@DynArraySetLength][36150]
00811B23 [uCommon.pas][uCommon][Mime64Decode][3729]
00928D49 [uXMLSec.pas][uXMLSec][NodeGetBase64Value][311]
0092B828 [uXMLSec.pas][uXMLSec][VerifyNode][893]
0092C0D4 [uXMLSec.pas][uXMLSec][TXMLSec.Verify][1006]
00D43D7A [Main.pas][Main][TMainForm.UpdateAttachmentsAndSignatures][298]
00D44784 [Main.pas][Main][TMainForm.LoadFile][427]
00D44886 [Main.pas][Main][TMainForm.BtnOpenClick][443]
00578075 [Vcl.Controls.pas][Vcl.Controls][TControl.Click][7536]
0059B84F [Vcl.StdCtrls.pas][Vcl.StdCtrls][TCustomButton.Click][5470]
0059C365 [Vcl.StdCtrls.pas][Vcl.StdCtrls][TCustomButton.CNCommand][5931]
00577B19 [Vcl.Controls.pas][Vcl.Controls][TControl.WndProc][7420]
75FD5E7A [Unknown function at GetClassLongW]
75FD60BF [Unknown function at GetClassLongW]
75FD5EBC [Unknown function at GetClassLongW]
function Mime64Decode(const Encoded:string):TBytes;
var
InLen ,
OutLen : NativeUInt;
Raw : RawByteString;
begin
Raw := RawByteString(Encoded);
InLen := Length(Encoded);
OutLen := 0;
if InLen>0 then
begin
OutLen := MimeDecodedSize(InLen);
SetLength(Result,OutLen);
try
OutLen := MimeDecode(Raw[1],InLen,Result[0]);
except
OutLen := 0;
end;
end;
SetLength(Result,OutLen);
end;
Is there any alternative to allocate memory to TBytes?
Best regards.