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

David Tardon dtardon at redhat.com
Wed Sep 28 23:19:17 PDT 2011


On Tue, Sep 27, 2011 at 10:11:11PM +0200, Maciej Rumianowski wrote:
> Hi *,
> 
> Simple Patch replacing SvULongs with std::vector. Related Bug 38831.

Pushed, thanks!

> @@ -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.

D.


More information about the LibreOffice mailing list