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


Hi,

I have submitted a patch for review:

    https://gerrit.libreoffice.org/2176

To pull it, you can do:

    git pull ssh://gerrit.libreoffice.org:29418/core refs/changes/76/2176/1

sw: do not crash when it's not possible to insert fly

Change-Id: Idfcf54013107ba6b7ce3de0d0bddbef306698f33
(cherry picked from commit 5a80c24b145c8efe0dd384ef88e7d31173522fb8)
---
M sw/source/core/doc/doclay.cxx
1 file changed, 14 insertions(+), 3 deletions(-)



diff --git a/sw/source/core/doc/doclay.cxx b/sw/source/core/doc/doclay.cxx
index f31c998..3bac734 100644
--- a/sw/source/core/doc/doclay.cxx
+++ b/sw/source/core/doc/doclay.cxx
@@ -654,7 +654,11 @@
         if (pTxtNode != NULL)
         {
             SwFmtFlyCnt aFmt( pFmt );
-            pTxtNode->InsertItem( aFmt, nStt, nStt );
+            bool const bSuccess( pTxtNode->InsertItem(aFmt, nStt, nStt) );
+            if (!bSuccess) // may fail if there's no space left or header/ftr
+            {   // pFmt is dead now
+                return 0;
+            }
         }
     }
 
@@ -740,7 +744,9 @@
         if (bCalledFromShell && !lcl_IsItemSet(*pNewTxtNd, RES_PARATR_ADJUST) &&
             SFX_ITEM_SET == pAnchorNode->GetSwAttrSet().
             GetItemState(RES_PARATR_ADJUST, sal_True, &pItem))
+        {
             static_cast<SwCntntNode *>(pNewTxtNd)->SetAttr(*pItem);
+        }
 
          pFmt = _MakeFlySection( *pAnchorPos, *pNewTxtNd,
                                 eAnchorType, pFlySet, pFrmFmt );
@@ -941,8 +947,13 @@
     {
         xub_StrLen nStt = rRg.GetPoint()->nContent.GetIndex();
         SwFmtFlyCnt aFmt( pFmt );
-        rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem(
-                aFmt, nStt, nStt );
+        bool const bSuccess( // may fail if there's no space left
+            rRg.GetPoint()->nNode.GetNode().GetTxtNode()->InsertItem(
+                    aFmt, nStt, nStt));
+        if (!bSuccess)
+        {   // pFmt is dead now
+            return 0;
+        }
     }
 
     SwDrawContact* pContact = new SwDrawContact( pFmt, &rDrawObj );

-- 
To view, visit https://gerrit.libreoffice.org/2176
To unsubscribe, visit https://gerrit.libreoffice.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: Idfcf54013107ba6b7ce3de0d0bddbef306698f33
Gerrit-PatchSet: 1
Gerrit-Project: core
Gerrit-Branch: libreoffice-4-0
Gerrit-Owner: Michael Stahl <mstahl@redhat.com>

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.