2020-3-23 21:26
MrOuzo
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
[code]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;[/code]
the correct code is
[code]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;[/code]
Greetings
MrOuzo