Talk About Network

Google


Register and Login
Nick
Password
Register create new account Sign up is FREE and you can post replies, new topics, bookmark posts and more!
Recover lost password


Programming > Pascal Delphi Misc > Re: [D7] Bug in...
Latest [ Topics | Posts ] Archive Post A New Topic Post a Reply
<< Topic < Post Post 2 of 13 Topic 6108 of 6157
Post > Topic >>

Re: [D7] Bug in TList.Sort

by Nicholas Sherlock <n.sherlock@[EMAIL PROTECTED] > Jul 17, 2008 at 11:06 PM

Hans-Peter Diettrich wrote:
> I wonder whether this bug has not been revealed before:
> 
> Before sorting a check of (Count > 0) is made, instead of > 1. An 
> attempt to sort a list with only 1 member will result in an Nil pointer 
> passed to the compare function, and BANG :-(
> 
> What about other (newer) Delphi versions?

I'm using Delphi 2008. While the compare function was (needlessly) 
called in this case, it got valid pointers passed to it. My test case 
was this:

function compare(item1,item2:pointer):integer;
begin
showmessage(inttostr(integer(item1))+','+inttostr(integer(item2)));
result:=integer(item2)-integer(item1);
end;

procedure TForm1.Button1Click(Sender: TObject);
var list:TList;
begin
  list:=TList.create;
  try
  list.add(pointer(1234));
  list.Sort(compare);
  finally
    list.free;
  end;
end;

The output is '1234,1234', '1234, 1234'.

Cheers,
Nicholas Sherlock
-----------------
www.Newsgroup-Binaries.com - *Completion*Retention*Speed*
Access your favorite newsgroups from home or on the road
-----------------
 




 13 Posts in Topic:
[D7] Bug in TList.Sort
Hans-Peter Diettrich <  2008-07-17 12:52:17 
Re: [D7] Bug in TList.Sort
Nicholas Sherlock <n.s  2008-07-17 23:06:23 
Re: [D7] Bug in TList.Sort
Rob Kennedy <me3@[EMAI  2008-07-17 07:40:44 
Re: [D7] Bug in TList.Sort
Hans-Peter Diettrich <  2008-07-17 16:04:51 
Re: [D7] Bug in TList.Sort
Rob Kennedy <me3@[EMAI  2008-07-17 17:48:44 
Re: [D7] Bug in TList.Sort
Hans-Peter Diettrich <  2008-07-18 02:19:24 
Re: [D7] Bug in TList.Sort
Rob Kennedy <me3@[EMAI  2008-07-17 21:21:59 
Re: [D7] Bug in TList.Sort
Hans-Peter Diettrich <  2008-07-18 10:59:46 
Re: [D7] Bug in TList.Sort
Nicholas Sherlock <n.s  2008-07-18 17:19:35 
Re: [D7] Bug in TList.Sort
"Tom de Neef" &  2008-07-17 16:41:20 
Re: [D7] Bug in TList.Sort
"BRoberts" <  2008-07-31 20:22:50 
Re: [D7] Bug in TList.Sort
Hans-Peter Diettrich <  2008-08-01 16:01:12 
Re: [D7] Bug in TList.Sort
Nicholas Sherlock <n.s  2008-08-02 21:39:25 

Post A Reply:
  Go here to Signup

AddThis Feed Button


About - Advertising - Contact - Frequently Asked Questions - Privacy Policy - Terms of Use - Signup

Contact
tan12V112 Mon Oct 13 11:12:18 CDT 2008.