Date: prev next · Thread: first prev next last
2011 Archives by date, by thread · List index


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


Context


Privacy Policy | Impressum (Legal Info) | Copyright information: Unless otherwise specified, all text and images on this website are licensed under the Creative Commons Attribution-Share Alike 3.0 License. This does not include the source code of LibreOffice, which is licensed under the Mozilla Public License (MPLv2). "LibreOffice" and "The Document Foundation" are registered trademarks of their corresponding registered owners or are in actual use as trademarks in one or more countries. Their respective logos and icons are also subject to international copyright laws. Use thereof is explained in our trademark policy.