Subject: Bug in cnDebug.pas AddTimeDesc [Print This Page]
Author:
MrOuzo Time: 2020-3-23 21:26 Subject: Bug in cnDebug.pas AddTimeDesc
Hello,
i found a bug in cnDebug.pas AddTimeDesc at line 1215
here there is an Ansiconversion from the wrong stringvariable
function TCnDebugger.AddTimeDesc(const ATag: string): PCnTimeDesc;
var
ADesc: PCnTimeDesc;
Len: Integer;
TTag: AnsiString;
begin
New(ADesc);
FillChar(ADesc^, SizeOf(TCnTimeDesc), 0);
TTag := AnsiString(TTag);
Len := Length(TTag);
if Len > CnMaxTagLength then
Len := CnMaxTagLength;
Move(PAnsiChar(TTag)^, ADesc^.Tag, Len);
FTimes.Add(ADesc);
Result := ADesc;
end;
the correct code is
function TCnDebugger.AddTimeDesc(const ATag: string): PCnTimeDesc;
var
ADesc: PCnTimeDesc;
Len: Integer;
TTag: AnsiString;
begin
New(ADesc);
FillChar(ADesc^, SizeOf(TCnTimeDesc), 0);
TTag := AnsiString(ATag); // <--- here the ATag and not TTag string to convert
Len := Length(TTag);
if Len > CnMaxTagLength then
Len := CnMaxTagLength;
Move(PAnsiChar(TTag)^, ADesc^.Tag, Len);
FTimes.Add(ADesc);
Result := ADesc;
end;
Greetings
MrOuzo
Author:
Passion Time: 2020-6-2 14:22
Yes. It's my typo fault. I correct it now. Thanks!
Welcome to CnPack Forum (http://bbs.cnpack.org/) |
Powered by Discuz! 5.0.0 |