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
[Solved] Any::dtor fails after it is picked [message #19137] Fri, 14 November 2008 19:14 Go to previous message
Mindtraveller is currently offline  Mindtraveller
Messages: 917
Registered: August 2007
Location: Russia, Moscow rgn.
Experienced Contributor

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; }

[Updated on: Fri, 14 November 2008 22:48]

Report message to a moderator

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


Current Time: Sun Apr 28 01:52:22 CEST 2024

Total time taken to generate the page: 0.03829 seconds