Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » [Solved] Any::dtor fails after it is picked
Re: [BUG?] Any::dtor fails after it is picked [message #19140 is a reply to message #19137] Fri, 14 November 2008 21:21 Go to previous message
mirek is currently offline  mirek
Messages: 13976
Registered: November 2005
Ultimate Member
Mindtraveller wrote on Fri, 14 November 2008 13:14

testcase:
Any aa;
ArrayMap<unsigned, Any> am; //just something to pick aa
am.AddPick(0,aa);//aa is now picked
//and we have exception when aa is to be destroyed 


cause:
The cause is internal Pick behaviour and Clear() member function. When object is picked, it`s internal ptr is set to (void *)1. When object is to be destroyed, it`s Clear() is called. But Clear() doesn`t check if ptr == (void *)1. It just checks if ptr is nonzero. What we have? Of course exception on trying to delete (*1);

proposal:
Change Clear() function to something like
	void Clear()                                  { if(ptr && !IsPicked()) delete ptr; ptr = NULL; }



Thanks, correct observation, fixed.

Mirek
 
Read Message
Read Message
Previous Topic: Vector::SetCount()
Next Topic: streaming [FEATURE REQUEST]
Goto Forum:
  


Current Time: Sat May 11 23:53:37 CEST 2024

Total time taken to generate the page: 0.01643 seconds