[Libreoffice] [PATCH][PUSHED] Replace-SvULongs-with-std-vector-in-sfx2

Maciej Rumianowski maciej.rumianowski at gmail.com
Thu Sep 29 01:33:50 PDT 2011


Hi David,
> > @@ -53,7 +54,7 @@ TYPEINIT1_FACTORY( SvxClipboardFmtItem, SfxPoolItem , new  SvxClipboardFmtItem(0
> >  SvxClipboardFmtItem_Impl::SvxClipboardFmtItem_Impl(
> >                              const SvxClipboardFmtItem_Impl& rCpy )
> >  {
> > -    aFmtIds.Insert( &rCpy.aFmtIds, 0 );
> > +    std::copy(rCpy.aFmtIds.begin(), rCpy.aFmtIds.end(), aFmtIds.begin());
> >      for( sal_uInt16 n = 0, nEnd = rCpy.aFmtNms.Count(); n < nEnd; ++n )
> >      {
> >          String* pStr = rCpy.aFmtNms[ n ];
> 
> This is totally wrong! The original line _inserts_ all items from
> rCpy.aFmtIds at the beginning of aFmtIds. std::copy _overwrites_ the
> first n elements of aFmtIds by items from the given range--this requires
> that aFmtIds has sufficient size. Since this is constructor, aFmtIds is
> always empty, therefore the line is practically guaranteed to corrupt
> memory (unless rCpy.aFmtIds is empty). I changed it to simple copy
> construction of aFmtIds from rCpy.aFmtIds.
Thanks, sorry for that. I thought if I am working on vector than i will
automatically resize, but I missed in description that I have to
manually resize.

Cheers,
	Maciej



More information about the LibreOffice mailing list