CnPack Forum » CnWizards IDE Wizards » Bug in cnDebug.pas AddTimeDesc


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

2020-6-2 14:22 Passion
Yes. It's my typo fault. I correct it now. Thanks!

页: [1]
查看完整版本: Bug in cnDebug.pas AddTimeDesc


Powered by Discuz! Archiver 5.0.0  © 2001-2006 Comsenz Inc.