CnPack Forum


 
Subject: Bug in cnDebug.pas AddTimeDesc
MrOuzo
新警察
Rank: 1



UID 41314
Digest Posts 0
Credits 14
Posts 4
点点分 14
Reading Access 10
Registered 2008-11-20
Status Offline
Post at 2020-3-23 21:26  Profile | Blog | P.M. 
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
Top
Passion (LiuXiao)
管理员
Rank: 9Rank: 9Rank: 9


UID 359
Digest Posts 19
Credits 6838
Posts 3591
点点分 6838
Reading Access 102
Registered 2004-3-28
Status Offline
Post at 2020-6-2 14:22  Profile | Blog | P.M. 
Yes. It's my typo fault. I correct it now. Thanks!
Top
 




All times are GMT++8, the time now is 2024-11-24 12:19

    本论坛支付平台由支付宝提供
携手打造安全诚信的交易社区 Powered by Discuz! 5.0.0  © 2001-2006 Comsenz Inc.
Processed in 0.007614 second(s), 9 queries , Gzip enabled

Clear Cookies - Contact Us - CnPack Website - Archiver - WAP