From: SourceForge.net <no...@so...> - 2012-04-23 10:06:57
|
Bugs item #3520583, was opened at 2012-04-23 03:06 Message generated for change (Tracker Item Submitted) made by wizardhobo You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=396644&aid=3520583&group_id=29557 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: Wizard Hobo (wizardhobo) Assigned to: Nobody/Anonymous (nobody) Summary: yasli::vector::insert fails if reserve reallocates memory Initial Comment: // $Id: yasli_vector.h 754 2006-10-17 19:59:11Z syntheticpp $ The implementation for yasli::vector::insert (line 402) uses the position parameter _after_ a call to reserve. But if the call to reserve resulted in a memory reallocation, this iterator has become invalid. Consequently, 'pos' on line 406 is incorrect and the insert call in line 407 also does "the wrong thing"TM. The solution is to calculate pos _before_ the reserve call and recalculate position from that _after_ the reserve call. const size_type pos = position - begin(); reserve(size() + 1); position = begin() + pos; insert(position, (size_type)1, x); return ebo_.beg_ + pos; ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=396644&aid=3520583&group_id=29557 |