[Libreoffice-commits] core.git: codemaker/source compilerplugins/clang cppcanvas/source cui/source editeng/source filter/source hwpfilter/source i18npool/source include/codemaker l10ntools/source lotuswordpro/source o3tl/qa registry/source sal/qa sccomp/source scripting/source sc/source sd/source starmath/source stoc/source svtools/source sw/source tools/source vcl/source

Noel Grandin noel.grandin at collabora.co.uk
Wed Feb 1 12:16:02 UTC 2017


 codemaker/source/codemaker/exceptiontree.cxx         |    9 -
 codemaker/source/cppumaker/cpputype.cxx              |    8 -
 codemaker/source/javamaker/javatype.cxx              |    4 
 compilerplugins/clang/useuniqueptr.cxx               |   47 +++++
 cppcanvas/source/mtfrenderer/emfplus.cxx             |    7 
 cui/source/dialogs/hltpbase.cxx                      |    5 
 editeng/source/outliner/outlvw.cxx                   |    5 
 filter/source/xsltdialog/xmlfiltersettingsdialog.cxx |   10 -
 hwpfilter/source/hwpreader.cxx                       |    4 
 i18npool/source/localedata/LocaleNode.cxx            |   17 --
 include/codemaker/exceptiontree.hxx                  |    3 
 l10ntools/source/lngmerge.cxx                        |    7 
 l10ntools/source/propmerge.cxx                       |    6 
 lotuswordpro/source/filter/lwpgrfobj.cxx             |    5 
 lotuswordpro/source/filter/lwpidxmgr.cxx             |   19 +-
 lotuswordpro/source/filter/lwppara.cxx               |    4 
 lotuswordpro/source/filter/lwptablelayout.cxx        |    5 
 o3tl/qa/test-sorted_vector.cxx                       |  150 ++++++++-----------
 registry/source/reflwrit.cxx                         |    4 
 registry/source/regimpl.cxx                          |    7 
 sal/qa/osl/process/osl_Thread.cxx                    |   10 -
 sal/qa/rtl/oustring/rtl_OUString2.cxx                |    5 
 sal/qa/rtl/process/rtl_Process.cxx                   |    5 
 sal/qa/rtl/random/rtl_random.cxx                     |   50 ++----
 sc/source/core/tool/chartpos.cxx                     |    3 
 sc/source/core/tool/rangeutl.cxx                     |    8 -
 sc/source/filter/rtf/eeimpars.cxx                    |    7 
 sc/source/ui/view/formatsh.cxx                       |    3 
 sccomp/source/solver/LpsolveSolver.cxx               |    6 
 scripting/source/stringresource/stringresource.cxx   |    8 -
 sd/source/filter/eppt/pptexsoundcollection.cxx       |    7 
 sd/source/filter/ppt/pptin.cxx                       |    8 -
 sd/source/filter/ppt/propread.cxx                    |   47 ++---
 sd/source/ui/docshell/docshel2.cxx                   |    5 
 sd/source/ui/unoidl/unomodel.cxx                     |    8 -
 starmath/source/mathmlexport.cxx                     |   12 -
 stoc/source/inspect/introspection.cxx                |    7 
 svtools/source/contnr/svtabbx.cxx                    |    5 
 sw/source/core/access/accfrmobjmap.cxx               |   11 -
 sw/source/core/access/accpara.cxx                    |    7 
 sw/source/core/crsr/crsrsh.cxx                       |    7 
 sw/source/core/doc/doccomp.cxx                       |   19 +-
 sw/source/core/frmedt/fecopy.cxx                     |    9 -
 sw/source/core/layout/paintfrm.cxx                   |    3 
 sw/source/core/text/pormulti.cxx                     |    5 
 sw/source/core/txtnode/fntcache.cxx                  |   72 ++++-----
 sw/source/core/unocore/unodraw.cxx                   |    5 
 sw/source/filter/html/swhtml.cxx                     |    4 
 sw/source/filter/ww8/wrtw8esh.cxx                    |    7 
 sw/source/filter/ww8/wrtww8.cxx                      |    8 -
 sw/source/filter/ww8/wrtww8gr.cxx                    |    3 
 sw/source/filter/ww8/ww8par2.cxx                     |    7 
 sw/source/filter/ww8/ww8scan.cxx                     |   36 ++--
 sw/source/ui/chrdlg/chardlg.cxx                      |    3 
 sw/source/uibase/dialog/SwSpellDialogChildWindow.cxx |    7 
 tools/source/generic/poly.cxx                        |    3 
 tools/source/inet/inetmime.cxx                       |    7 
 vcl/source/gdi/bitmap4.cxx                           |    6 
 vcl/source/gdi/impgraph.cxx                          |    8 -
 vcl/source/gdi/salgdilayout.cxx                      |   10 -
 60 files changed, 341 insertions(+), 436 deletions(-)

New commits:
commit 2489000d3fd66319a8355fd4e37cfdfda47296d0
Author: Noel Grandin <noel.grandin at collabora.co.uk>
Date:   Tue Jan 31 14:46:38 2017 +0200

    loplugin:useuniqueptr extend to check local vars
    
    just the simple and obvious case for now, of a local var being allocated
    and deleted inside a single local block, and the delete happening at the
    end of the block
    
    Change-Id: I3a7a094da543debdcd2374737c2ecff91d644625
    Reviewed-on: https://gerrit.libreoffice.org/33749
    Tested-by: Jenkins <ci at libreoffice.org>
    Reviewed-by: Noel Grandin <noel.grandin at collabora.co.uk>

diff --git a/codemaker/source/codemaker/exceptiontree.cxx b/codemaker/source/codemaker/exceptiontree.cxx
index 0f63a5b..e9edd6d 100644
--- a/codemaker/source/codemaker/exceptiontree.cxx
+++ b/codemaker/source/codemaker/exceptiontree.cxx
@@ -36,14 +36,11 @@ using codemaker::ExceptionTreeNode;
 
 ExceptionTreeNode * ExceptionTreeNode::add(rtl::OString const & theName) {
     std::unique_ptr< ExceptionTreeNode > node(new ExceptionTreeNode(theName));
-    children.push_back(node.get());
-    return node.release();
+    children.push_back(std::move(node));
+    return children.back().get();
 }
 
 void ExceptionTreeNode::clearChildren() {
-    for (ExceptionTreeNode* child : children) {
-        delete child;
-    }
     children.clear();
 }
 
@@ -85,7 +82,7 @@ void ExceptionTree::add(
                     break;
                 }
                 if ((*j)->name == *i) {
-                    node = *j;
+                    node = j->get();
                     break;
                 }
             }
diff --git a/codemaker/source/cppumaker/cpputype.cxx b/codemaker/source/cppumaker/cpputype.cxx
index 47aab6c..6432bae 100644
--- a/codemaker/source/cppumaker/cpputype.cxx
+++ b/codemaker/source/cppumaker/cpputype.cxx
@@ -3359,9 +3359,9 @@ void includeExceptions(
     if (node->present) {
         includes.add(node->name);
     } else {
-        for (codemaker::ExceptionTreeNode* pChild : node->children)
+        for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children)
         {
-            includeExceptions(includes, pChild);
+            includeExceptions(includes, pChild.get());
         }
     }
 }
@@ -3713,9 +3713,9 @@ void ServiceType::dumpCatchClauses(
         out << indent() << "throw;\n";
         dec();
     } else {
-        for (codemaker::ExceptionTreeNode* pChild : node->children)
+        for (std::unique_ptr<codemaker::ExceptionTreeNode> const & pChild : node->children)
         {
-            dumpCatchClauses(out, pChild);
+            dumpCatchClauses(out, pChild.get());
         }
     }
 }
diff --git a/codemaker/source/javamaker/javatype.cxx b/codemaker/source/javamaker/javatype.cxx
index 1d414a1..2da2e5f 100644
--- a/codemaker/source/javamaker/javatype.cxx
+++ b/codemaker/source/javamaker/javatype.cxx
@@ -2087,9 +2087,9 @@ void addExceptionHandlers(
     if (node->present) {
         code->addException(start, end, handler, node->name.replace('.', '/'));
     } else {
-        for (codemaker::ExceptionTreeNode* p : node->children)
+        for (std::unique_ptr<codemaker::ExceptionTreeNode> const & p : node->children)
         {
-            addExceptionHandlers(p, start, end, handler, code);
+            addExceptionHandlers(p.get(), start, end, handler, code);
         }
     }
 }
diff --git a/compilerplugins/clang/useuniqueptr.cxx b/compilerplugins/clang/useuniqueptr.cxx
index 82d95e5..155fa0e 100644
--- a/compilerplugins/clang/useuniqueptr.cxx
+++ b/compilerplugins/clang/useuniqueptr.cxx
@@ -32,7 +32,8 @@ public:
         TraverseDecl(compiler.getASTContext().getTranslationUnitDecl());
     }
 
-    bool VisitCXXDestructorDecl(const CXXDestructorDecl* );
+    bool VisitCXXDestructorDecl(const CXXDestructorDecl * );
+    bool VisitCompoundStmt(const CompoundStmt * );
 };
 
 bool UseUniquePtr::VisitCXXDestructorDecl(const CXXDestructorDecl* destructorDecl)
@@ -130,6 +131,50 @@ bool UseUniquePtr::VisitCXXDestructorDecl(const CXXDestructorDecl* destructorDec
     return true;
 }
 
+bool UseUniquePtr::VisitCompoundStmt(const CompoundStmt* compoundStmt)
+{
+    if (ignoreLocation(compoundStmt))
+        return true;
+    if (isInUnoIncludeFile(compoundStmt->getLocStart()))
+        return true;
+    if (compoundStmt->size() == 0) {
+        return true;
+    }
+
+    const CXXDeleteExpr* deleteExpr = dyn_cast<CXXDeleteExpr>(compoundStmt->body_back());
+    if (deleteExpr == nullptr) {
+        return true;
+    }
+
+    const ImplicitCastExpr* pCastExpr = dyn_cast<ImplicitCastExpr>(deleteExpr->getArgument());
+    if (!pCastExpr)
+        return true;
+    const DeclRefExpr* declRefExpr = dyn_cast<DeclRefExpr>(pCastExpr->getSubExpr());
+    if (!declRefExpr)
+        return true;
+    const VarDecl* varDecl = dyn_cast<VarDecl>(declRefExpr->getDecl());
+    if (!varDecl)
+        return true;
+    if (!varDecl->hasInit() || !dyn_cast<CXXNewExpr>(varDecl->getInit()))
+        return true;
+    // determine if the var is declared inside the same block as the delete.
+    // @TODO there should surely be a better way to do this
+    if (varDecl->getLocStart() < compoundStmt->getLocStart())
+        return true;
+
+    report(
+        DiagnosticsEngine::Warning,
+        "deleting a local variable at the end of a block, is a sure sign it should be using std::unique_ptr for that var",
+        deleteExpr->getLocStart())
+        << deleteExpr->getSourceRange();
+    report(
+        DiagnosticsEngine::Note,
+        "var is here",
+        varDecl->getLocStart())
+        << varDecl->getSourceRange();
+    return true;
+}
+
 loplugin::Plugin::Registration< UseUniquePtr > X("useuniqueptr");
 
 }
diff --git a/cppcanvas/source/mtfrenderer/emfplus.cxx b/cppcanvas/source/mtfrenderer/emfplus.cxx
index 11dbf62..bb8f0a8 100644
--- a/cppcanvas/source/mtfrenderer/emfplus.cxx
+++ b/cppcanvas/source/mtfrenderer/emfplus.cxx
@@ -1383,8 +1383,8 @@ namespace cppcanvas
                         SAL_INFO("cppcanvas.emf", "EMF+\tglyphs: " << glyphsCount);
 
                         if( ( optionFlags & 1 ) && glyphsCount > 0 ) {
-                            float *charsPosX = new float[glyphsCount];
-                            float *charsPosY = new float[glyphsCount];
+                            std::unique_ptr<float[]> charsPosX( new float[glyphsCount] );
+                            std::unique_ptr<float[]> charsPosY( new float[glyphsCount] );
 
                             OUString text = read_uInt16s_ToOUString(rMF, glyphsCount);
 
@@ -1435,9 +1435,6 @@ namespace cppcanvas
 
                                 rFactoryParms.mrCurrActionIndex += pTextAction->getActionCount()-1;
                             }
-
-                            delete[] charsPosX;
-                            delete[] charsPosY;
                         } else {
                             SAL_INFO("cppcanvas.emf", "EMF+\tTODO: fonts (non-unicode glyphs chars)");
                         }
diff --git a/cui/source/dialogs/hltpbase.cxx b/cui/source/dialogs/hltpbase.cxx
index d8cfadf..7fefb04 100644
--- a/cui/source/dialogs/hltpbase.cxx
+++ b/cui/source/dialogs/hltpbase.cxx
@@ -320,9 +320,9 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, void)
             aItem.SetMacroTable( *pMacroTbl );
 
         // create empty itemset for macro-dlg
-        SfxItemSet* pItemSet = new SfxItemSet(SfxGetpApp()->GetPool(),
+        std::unique_ptr<SfxItemSet> pItemSet( new SfxItemSet(SfxGetpApp()->GetPool(),
                                               SID_ATTR_MACROITEM,
-                                              SID_ATTR_MACROITEM );
+                                              SID_ATTR_MACROITEM ) );
         pItemSet->Put ( aItem );
 
         /*  disable HyperLinkDlg for input while the MacroAssignDlg is working
@@ -362,7 +362,6 @@ IMPL_LINK_NOARG(SvxHyperlinkTabPageBase, ClickScriptHdl_Impl, Button*, void)
                 pHyperlinkItem->SetMacroTable( static_cast<const SvxMacroItem*>(pItem)->GetMacroTable() );
             }
         }
-        delete pItemSet;
     }
 }
 
diff --git a/editeng/source/outliner/outlvw.cxx b/editeng/source/outliner/outlvw.cxx
index 2c176c2..18c072b 100644
--- a/editeng/source/outliner/outlvw.cxx
+++ b/editeng/source/outliner/outlvw.cxx
@@ -1075,11 +1075,10 @@ void OutlinerView::ApplyBulletsNumbering(
                                 const SvxNumberFormat* pNewFmt = aNewRule.Get(nLevel);
                                 if (pOldFmt && pNewFmt && (pOldFmt->GetFirstLineOffset() != pNewFmt->GetFirstLineOffset() || pOldFmt->GetAbsLSpace() != pNewFmt->GetAbsLSpace()))
                                 {
-                                    SvxNumberFormat* pNewFmtClone = new SvxNumberFormat(*pNewFmt);
+                                    std::unique_ptr<SvxNumberFormat> pNewFmtClone(new SvxNumberFormat(*pNewFmt));
                                     pNewFmtClone->SetFirstLineOffset(pOldFmt->GetFirstLineOffset());
                                     pNewFmtClone->SetAbsLSpace(pOldFmt->GetAbsLSpace());
-                                    aNewRule.SetLevel(nLevel, pNewFmtClone);
-                                    delete pNewFmtClone;
+                                    aNewRule.SetLevel(nLevel, pNewFmtClone.get());
                                 }
                             }
                         }
diff --git a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
index a99d35a..1c0bc8f 100644
--- a/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
+++ b/filter/source/xsltdialog/xmlfiltersettingsdialog.cxx
@@ -1040,7 +1040,7 @@ void XMLFilterSettingsDialog::initFilterList()
 
         Sequence< PropertyValue > aValues;
 
-        filter_info_impl* pTempFilter = new filter_info_impl;
+        std::unique_ptr<filter_info_impl> pTempFilter( new filter_info_impl );
         Sequence< OUString > aUserData;
 
         for( nFilter = 0; nFilter < nCount; nFilter++, pFilterName++ )
@@ -1187,11 +1187,11 @@ void XMLFilterSettingsDialog::initFilterList()
                 }
 
                 // add entry to internal container and to ui filter list box
-                maFilterVector.push_back( pTempFilter );
-                m_pFilterListBox->addFilterEntry( pTempFilter );
+                maFilterVector.push_back( pTempFilter.get() );
+                m_pFilterListBox->addFilterEntry( pTempFilter.release() );
 
 
-                pTempFilter = new filter_info_impl;
+                pTempFilter.reset( new filter_info_impl );
             }
             catch( const Exception& )
             {
@@ -1199,8 +1199,6 @@ void XMLFilterSettingsDialog::initFilterList()
             }
 
         }
-
-        delete pTempFilter;
     }
 
     SvTreeListEntry* pEntry = m_pFilterListBox->GetEntry( 0 );
diff --git a/hwpfilter/source/hwpreader.cxx b/hwpfilter/source/hwpreader.cxx
index deb3b26..1542602 100644
--- a/hwpfilter/source/hwpreader.cxx
+++ b/hwpfilter/source/hwpreader.cxx
@@ -3707,12 +3707,10 @@ void HwpReader::makeFormula(TxtBox * hbox)
     }
     mybuf[l] = '\0';
 
-    Formula *form = new Formula(mybuf);
+    std::unique_ptr<Formula> form( new Formula(mybuf) );
     form->setDocumentHandler(m_rxDocumentHandler);
     form->setAttributeListImpl(mxList.get());
     form->parse();
-
-    delete form;
 }
 
 /**
diff --git a/i18npool/source/localedata/LocaleNode.cxx b/i18npool/source/localedata/LocaleNode.cxx
index 9f778e4..b411e38 100644
--- a/i18npool/source/localedata/LocaleNode.cxx
+++ b/i18npool/source/localedata/LocaleNode.cxx
@@ -22,6 +22,7 @@
 #include <string.h>
 #include <algorithm>
 #include <iostream>
+#include <memory>
 #include <set>
 #include <vector>
 
@@ -1621,11 +1622,11 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
     }
     sal_Int16 nbOfCalendars = sal::static_int_cast<sal_Int16>( getNumberOfChildren() );
     OUString str;
-    sal_Int16 * nbOfDays = new sal_Int16[nbOfCalendars];
-    sal_Int16 * nbOfMonths = new sal_Int16[nbOfCalendars];
-    sal_Int16 * nbOfGenitiveMonths = new sal_Int16[nbOfCalendars];
-    sal_Int16 * nbOfPartitiveMonths = new sal_Int16[nbOfCalendars];
-    sal_Int16 * nbOfEras = new sal_Int16[nbOfCalendars];
+    std::unique_ptr<sal_Int16[]> nbOfDays( new sal_Int16[nbOfCalendars] );
+    std::unique_ptr<sal_Int16[]> nbOfMonths( new sal_Int16[nbOfCalendars] );
+    std::unique_ptr<sal_Int16[]> nbOfGenitiveMonths( new sal_Int16[nbOfCalendars] );
+    std::unique_ptr<sal_Int16[]> nbOfPartitiveMonths( new sal_Int16[nbOfCalendars] );
+    std::unique_ptr<sal_Int16[]> nbOfEras( new sal_Int16[nbOfCalendars] );
     sal_Int16 j;
     sal_Int16 i;
     bool bHasGregorian = false;
@@ -1914,12 +1915,6 @@ void LCCalendarNode::generateCode (const OFileWriter &of) const
 
     of.writeAsciiString("};\n\n");
     of.writeFunction("getAllCalendars_", "calendarsCount", "calendars");
-
-    delete []nbOfDays;
-    delete []nbOfMonths;
-    delete []nbOfGenitiveMonths;
-    delete []nbOfPartitiveMonths;
-    delete []nbOfEras;
 }
 
 bool isIso4217( const OUString& rStr )
diff --git a/include/codemaker/exceptiontree.hxx b/include/codemaker/exceptiontree.hxx
index 8058cc8..7118006 100644
--- a/include/codemaker/exceptiontree.hxx
+++ b/include/codemaker/exceptiontree.hxx
@@ -24,6 +24,7 @@
 #include <rtl/ref.hxx>
 #include <rtl/string.hxx>
 
+#include <memory>
 #include <vector>
 
 class TypeManager;
@@ -34,7 +35,7 @@ namespace codemaker {
    Represents a node of the hierarchy from the ExceptionTree class.
  */
 struct ExceptionTreeNode {
-    typedef std::vector< ExceptionTreeNode * > Children;
+    typedef std::vector< std::unique_ptr<ExceptionTreeNode> > Children;
 
     // Internally used by ExceptionTree:
     ExceptionTreeNode(rtl::OString const & theName):
diff --git a/l10ntools/source/lngmerge.cxx b/l10ntools/source/lngmerge.cxx
index a1de58d..0411e1c 100644
--- a/l10ntools/source/lngmerge.cxx
+++ b/l10ntools/source/lngmerge.cxx
@@ -22,6 +22,7 @@
 #include <cstddef>
 #include <fstream>
 #include <iterator>
+#include <memory>
 #include <string>
 
 #include "po.hxx"
@@ -196,9 +197,9 @@ bool LngParser::Merge(
         OString sID( sGroup );
         std::size_t nLastLangPos = 0;
 
-        ResData  *pResData = new ResData( sID, sSource );
+        std::unique_ptr<ResData> pResData( new ResData( sID, sSource ) );
         pResData->sResTyp = "LngText";
-        MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( pResData );
+        MergeEntrys *pEntrys = aMergeDataFile.GetMergeEntrys( pResData.get() );
         // read languages
         bGroup = false;
 
@@ -305,8 +306,6 @@ bool LngParser::Merge(
                 }
             }
         }
-
-        delete pResData;
     }
 
     for ( size_t i = 0; i < pLines->size(); ++i )
diff --git a/l10ntools/source/propmerge.cxx b/l10ntools/source/propmerge.cxx
index e4e75f6..3a7c92b 100644
--- a/l10ntools/source/propmerge.cxx
+++ b/l10ntools/source/propmerge.cxx
@@ -166,10 +166,10 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil
         return;
     }
 
-    MergeDataFile* pMergeDataFile = nullptr;
+    std::unique_ptr<MergeDataFile> pMergeDataFile;
     if( m_sLang != "qtz" )
     {
-        pMergeDataFile = new MergeDataFile( rMergeSrc, m_sSource, false, false );
+        pMergeDataFile.reset( new MergeDataFile( rMergeSrc, m_sSource, false, false ) );
 
         const std::vector<OString> vLanguages = pMergeDataFile->GetLanguages();
         if( vLanguages.size()>=1 && vLanguages[0] != m_sLang )
@@ -179,7 +179,6 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil
                     " Mergedata file: ")
                 << m_sLang.getStr() << " - "
                 << vLanguages[0].getStr() << std::endl;
-            delete pMergeDataFile;
             return;
         }
     }
@@ -225,7 +224,6 @@ void PropParser::Merge( const OString &rMergeSrc, const OString &rDestinationFil
         }
     }
     aDestination.close();
-    delete pMergeDataFile;
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx
index 882f7d2..b28a52e 100644
--- a/lotuswordpro/source/filter/lwpgrfobj.cxx
+++ b/lotuswordpro/source/filter/lwpgrfobj.cxx
@@ -698,13 +698,12 @@ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont)
         bOk &= nEnd >= nBegin;
         if (bOk)
         {
-            sal_uInt8* pEquData = new sal_uInt8[nEnd - nBegin + 1];
+            std::unique_ptr<sal_uInt8[]> pEquData( new sal_uInt8[nEnd - nBegin + 1] );
             for(sal_uInt32 nIndex = 0; nIndex < nEnd - nBegin +1 ; nIndex++)
             {
                 pEquData[nIndex] = pGrafData[nBegin + nIndex];
             }
-            pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
-            delete [] pEquData;
+            pXFNotePara->Add(OUString(reinterpret_cast<char*>(pEquData.get()), (nEnd - nBegin + 1), osl_getThreadTextEncoding()));
         }
         pXFNote->Add(pXFNotePara);
 
diff --git a/lotuswordpro/source/filter/lwpidxmgr.cxx b/lotuswordpro/source/filter/lwpidxmgr.cxx
index 8d02521..3b6b3a7 100644
--- a/lotuswordpro/source/filter/lwpidxmgr.cxx
+++ b/lotuswordpro/source/filter/lwpidxmgr.cxx
@@ -68,6 +68,7 @@
 
 #include "lwpidxmgr.hxx"
 #include "lwptools.hxx"
+#include <memory>
 
 const sal_uInt8 LwpIndexManager::MAXOBJECTIDS = 255;
 
@@ -246,19 +247,17 @@ void LwpIndexManager::ReadObjIndex( LwpSvStream *pStrm )
 
     LwpObjectHeader ObjHdr;
     ObjHdr.Read(*pStrm);
-    LwpObjectStream* pObjStrm = new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
-            static_cast<sal_uInt16>(ObjHdr.GetSize()) );
+    std::unique_ptr<LwpObjectStream> pObjStrm( new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
+            static_cast<sal_uInt16>(ObjHdr.GetSize()) ) );
 
     if( (sal_uInt32)VO_OBJINDEX == ObjHdr.GetTag() )
     {
-        ReadObjIndexData( pObjStrm );
+        ReadObjIndexData( pObjStrm.get() );
     }
     else if( (sal_uInt32)VO_LEAFOBJINDEX == ObjHdr.GetTag() )
     {
-        ReadLeafData(pObjStrm);
+        ReadLeafData( pObjStrm.get() );
     }
-
-    delete pObjStrm;
 }
 
 /**
@@ -268,12 +267,10 @@ void LwpIndexManager::ReadLeafIndex( LwpSvStream *pStrm )
 {
     LwpObjectHeader ObjHdr;
     ObjHdr.Read(*pStrm);
-    LwpObjectStream* pObjStrm = new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
-            static_cast<sal_uInt16>(ObjHdr.GetSize()) );
-
-    ReadLeafData(pObjStrm);
+    std::unique_ptr<LwpObjectStream> pObjStrm( new LwpObjectStream(pStrm, ObjHdr.IsCompressed(),
+            static_cast<sal_uInt16>(ObjHdr.GetSize()) ) );
 
-    delete pObjStrm;
+    ReadLeafData(pObjStrm.get());
 }
 /**
  * @descr   Read data in VO_LEAFOBJINDEX
diff --git a/lotuswordpro/source/filter/lwppara.cxx b/lotuswordpro/source/filter/lwppara.cxx
index d5ad196..82192ec 100644
--- a/lotuswordpro/source/filter/lwppara.cxx
+++ b/lotuswordpro/source/filter/lwppara.cxx
@@ -95,6 +95,7 @@
 
 #include "lwpdropcapmgr.hxx"
 #include "lwptable.hxx"
+#include <memory>
 
 LwpPara::LwpPara(LwpObjectHeader& objHdr, LwpSvStream* pStrm)
     : LwpDLVList(objHdr, pStrm)
@@ -194,10 +195,9 @@ void LwpPara::Read()
         {
             if (Notify)
             {
-                LwpForked3NotifyList* pNotifyList = new LwpForked3NotifyList();
+                std::unique_ptr<LwpForked3NotifyList> pNotifyList( new LwpForked3NotifyList );
                 pNotifyList->GetExtraList().Read(m_pObjStrm.get());
                 pNotifyList->Read(m_pObjStrm.get());
-                delete pNotifyList;
             }
         }
     }
diff --git a/lotuswordpro/source/filter/lwptablelayout.cxx b/lotuswordpro/source/filter/lwptablelayout.cxx
index 76f681a..c9acba7 100644
--- a/lotuswordpro/source/filter/lwptablelayout.cxx
+++ b/lotuswordpro/source/filter/lwptablelayout.cxx
@@ -82,6 +82,7 @@
 #include "xfilter/xffloatframe.hxx"
 #include "lwpframelayout.hxx"
 #include "xfilter/xfparastyle.hxx"
+#include <memory>
 
 LwpSuperTableLayout::LwpSuperTableLayout(LwpObjectHeader &objHdr, LwpSvStream* pStrm)
     : LwpPlacableLayout(objHdr, pStrm)
@@ -560,7 +561,7 @@ void LwpTableLayout::RegisterColumns()
     sal_uInt16 nCols = m_nCols;
 
     m_pColumns = new LwpColumnLayout *[nCols];
-    sal_Bool * pWidthCalculated = new sal_Bool[nCols];
+    std::unique_ptr<bool[]> pWidthCalculated( new bool[nCols] );
     for(sal_uInt16 i=0;i<nCols; i++)
     {
         pWidthCalculated[i] = false;
@@ -581,7 +582,6 @@ void LwpTableLayout::RegisterColumns()
         auto nColId = pColumnLayout->GetColumnID();
         if (nColId >= nCols)
         {
-            delete [] pWidthCalculated;
             throw std::range_error("corrupt LwpTableLayout");
         }
         m_pColumns[nColId] = pColumnLayout;
@@ -642,7 +642,6 @@ void LwpTableLayout::RegisterColumns()
             }
         }
     }
-    delete [] pWidthCalculated;
 }
 /**
  * @short    register all row styles
diff --git a/o3tl/qa/test-sorted_vector.cxx b/o3tl/qa/test-sorted_vector.cxx
index 471ca7e..3f05381 100644
--- a/o3tl/qa/test-sorted_vector.cxx
+++ b/o3tl/qa/test-sorted_vector.cxx
@@ -36,41 +36,38 @@ public:
     void testBasics()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec;
-        SwContent *p1 = new SwContent(1);
-        SwContent *p2 = new SwContent(2);
+        std::unique_ptr<SwContent> p1( new SwContent(1) );
+        std::unique_ptr<SwContent> p2( new SwContent(2) );
         SwContent *p3 = new SwContent(3);
-        SwContent *p4 = new SwContent(4);
+        std::unique_ptr<SwContent> p4( new SwContent(4) );
 
         CPPUNIT_ASSERT( aVec.insert(p3).second );
-        CPPUNIT_ASSERT( aVec.insert(p1).second );
+        CPPUNIT_ASSERT( aVec.insert(p1.get()).second );
         CPPUNIT_ASSERT( !aVec.insert(p3).second );
 
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
 
-        CPPUNIT_ASSERT_EQUAL( p1, aVec[0] );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), aVec[0] );
         CPPUNIT_ASSERT_EQUAL( p3, aVec[1] );
 
-        CPPUNIT_ASSERT_EQUAL( p1, *aVec.begin() );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), *aVec.begin() );
         CPPUNIT_ASSERT_EQUAL( p3, *(aVec.end()-1) );
 
-        CPPUNIT_ASSERT_EQUAL( p1, aVec.front() );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), aVec.front() );
         CPPUNIT_ASSERT_EQUAL( p3, aVec.back() );
 
-        CPPUNIT_ASSERT( aVec.find(p1) != aVec.end() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(0), aVec.find(p1) - aVec.begin() );
+        CPPUNIT_ASSERT( aVec.find(p1.get()) != aVec.end() );
+        CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(0), aVec.find(p1.get()) - aVec.begin() );
         CPPUNIT_ASSERT( aVec.find(p3) != aVec.end() );
         CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(1), aVec.find(p3) - aVec.begin() );
-        CPPUNIT_ASSERT( bool(aVec.find(p2) == aVec.end()) );
-        CPPUNIT_ASSERT( bool(aVec.find(p4) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p2.get()) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p4.get()) == aVec.end()) );
 
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1.get()) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.size() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p2) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p2.get()) );
 
         aVec.DeleteAndDestroyAll();
-        delete p1;
-        delete p2;
-        delete p4;
     }
 
     void testErase()
@@ -79,7 +76,7 @@ public:
         SwContent *p1 = new SwContent(1);
         SwContent *p2 = new SwContent(2);
         SwContent *p3 = new SwContent(3);
-        SwContent *p4 = new SwContent(4);
+        std::unique_ptr<SwContent> p4( new SwContent(4) );
 
         aVec.insert(p1);
         aVec.insert(p2);
@@ -91,7 +88,7 @@ public:
         aVec.erase(1);
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.size() );
 
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4.get()) );
 
         aVec.clear();
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.size() );
@@ -101,162 +98,147 @@ public:
         aVec.insert(p3);
         aVec.DeleteAndDestroyAll();
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.size() );
-        delete p4;
     }
 
     void testInsertRange()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec1;
-        SwContent *p1 = new SwContent(1);
-        SwContent *p2 = new SwContent(2);
-        SwContent *p3 = new SwContent(3);
+        std::unique_ptr<SwContent> p1( new SwContent(1) );
+        std::unique_ptr<SwContent> p2( new SwContent(2) );
+        std::unique_ptr<SwContent> p3( new SwContent(3) );
 
-        aVec1.insert(p1);
-        aVec1.insert(p2);
-        aVec1.insert(p3);
+        aVec1.insert(p1.get());
+        aVec1.insert(p2.get());
+        aVec1.insert(p3.get());
 
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec2;
         aVec2.insert( aVec1 );
 
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(3), aVec2.size() );
-        delete p1;
-        delete p2;
-        delete p3;
     }
 
     void testLowerBound()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent> > aVec;
-        SwContent *p1 = new SwContent(1);
-        SwContent *p2 = new SwContent(2);
-        SwContent *p3 = new SwContent(3);
-        SwContent *p4 = new SwContent(4);
+        std::unique_ptr<SwContent> p1( new SwContent(1) );
+        std::unique_ptr<SwContent> p2( new SwContent(2) );
+        std::unique_ptr<SwContent> p3( new SwContent(3) );
+        std::unique_ptr<SwContent> p4( new SwContent(4) );
 
-        aVec.insert(p1);
-        aVec.insert(p2);
-        aVec.insert(p3);
+        aVec.insert(p1.get());
+        aVec.insert(p2.get());
+        aVec.insert(p3.get());
 
-        CPPUNIT_ASSERT( bool(aVec.lower_bound(p1) == aVec.begin()) );
-        CPPUNIT_ASSERT( bool(aVec.lower_bound(p4) == aVec.end()) );
-        delete p1;
-        delete p2;
-        delete p3;
-        delete p4;
+        CPPUNIT_ASSERT( bool(aVec.lower_bound(p1.get()) == aVec.begin()) );
+        CPPUNIT_ASSERT( bool(aVec.lower_bound(p4.get()) == aVec.end()) );
     }
 
     void testBasics_FindPtr()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
             o3tl::find_partialorder_ptrequals> aVec;
-        SwContent *p1 = new SwContent(1);
-        SwContent *p2 = new SwContent(2);
+        std::unique_ptr<SwContent> p1( new SwContent(1) );
+        std::unique_ptr<SwContent> p2( new SwContent(2) );
         SwContent *p2_2 = new SwContent(2);
-        SwContent *p2_3 = new SwContent(2);
+        std::unique_ptr<SwContent> p2_3( new SwContent(2) );
         SwContent *p2_4 = new SwContent(2);
         SwContent *p3 = new SwContent(3);
-        SwContent *p4 = new SwContent(4);
+        std::unique_ptr<SwContent> p4( new SwContent(4) );
 
         CPPUNIT_ASSERT( aVec.insert(p3).second );
-        CPPUNIT_ASSERT( aVec.insert(p1).second );
+        CPPUNIT_ASSERT( aVec.insert(p1.get()).second );
         CPPUNIT_ASSERT( !aVec.insert(p3).second );
 
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
 
-        CPPUNIT_ASSERT_EQUAL( p1, aVec[0] );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), aVec[0] );
         CPPUNIT_ASSERT_EQUAL( p3, aVec[1] );
 
         CPPUNIT_ASSERT( aVec.insert(p2_2).second );
-        CPPUNIT_ASSERT( aVec.insert(p2_3).second );
+        CPPUNIT_ASSERT( aVec.insert(p2_3.get()).second );
         CPPUNIT_ASSERT( !aVec.insert(p2_2).second );
         CPPUNIT_ASSERT( aVec.insert(p2_4).second );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(5), aVec.size() );
 
-        CPPUNIT_ASSERT_EQUAL( p1, *aVec.begin() );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), *aVec.begin() );
         CPPUNIT_ASSERT_EQUAL( p3, *(aVec.end()-1) );
 
-        CPPUNIT_ASSERT_EQUAL( p1, aVec.front() );
+        CPPUNIT_ASSERT_EQUAL( p1.get(), aVec.front() );
         CPPUNIT_ASSERT_EQUAL( p3, aVec.back() );
 
-        CPPUNIT_ASSERT( aVec.find(p1) != aVec.end() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(0), aVec.find(p1) - aVec.begin() );
+        CPPUNIT_ASSERT( aVec.find(p1.get()) != aVec.end() );
+        CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(0), aVec.find(p1.get()) - aVec.begin() );
         CPPUNIT_ASSERT( aVec.find(p3) != aVec.end() );
         CPPUNIT_ASSERT_EQUAL( static_cast<std::ptrdiff_t>(4), aVec.find(p3) - aVec.begin() );
-        CPPUNIT_ASSERT( bool(aVec.find(p2) == aVec.end()) );
-        CPPUNIT_ASSERT( bool(aVec.find(p4) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p2.get()) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p4.get()) == aVec.end()) );
         CPPUNIT_ASSERT( aVec.find(p2_2) != aVec.end() );
         CPPUNIT_ASSERT( aVec.find(p2_2) - aVec.begin() >= 1 );
         CPPUNIT_ASSERT( aVec.find(p2_2) - aVec.begin() <  4 );
-        CPPUNIT_ASSERT( aVec.find(p2_3) != aVec.end() );
-        CPPUNIT_ASSERT( aVec.find(p2_3) - aVec.begin() >= 1 );
-        CPPUNIT_ASSERT( aVec.find(p2_3) - aVec.begin() <  4 );
+        CPPUNIT_ASSERT( aVec.find(p2_3.get()) != aVec.end() );
+        CPPUNIT_ASSERT( aVec.find(p2_3.get()) - aVec.begin() >= 1 );
+        CPPUNIT_ASSERT( aVec.find(p2_3.get()) - aVec.begin() <  4 );
         CPPUNIT_ASSERT( aVec.find(p2_4) != aVec.end() );
         CPPUNIT_ASSERT( aVec.find(p2_4) - aVec.begin() >= 1 );
         CPPUNIT_ASSERT( aVec.find(p2_4) - aVec.begin() <  4 );
 
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1.get()) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(4), aVec.size() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p2) );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p2_3) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p2.get()) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p2_3.get()) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(3), aVec.size() );
 
         aVec.DeleteAndDestroyAll();
-        delete p1;
-        delete p2;
-        delete p2_3;
-        delete p4;
     }
 
     void testErase_FindPtr()
     {
         o3tl::sorted_vector<SwContent*, o3tl::less_ptr_to<SwContent>,
             o3tl::find_partialorder_ptrequals> aVec;
-        SwContent *p1 = new SwContent(1);
+        std::unique_ptr<SwContent> p1( new SwContent(1) );
         SwContent *p1_2 = new SwContent(1);
-        SwContent *p1_3 = new SwContent(1);
+        std::unique_ptr<SwContent> p1_3( new SwContent(1) );
         SwContent *p2 = new SwContent(2);
         SwContent *p3 = new SwContent(3);
-        SwContent *p4 = new SwContent(4);
+        std::unique_ptr<SwContent> p4( new SwContent(4) );
 
-        aVec.insert(p1);
+        aVec.insert(p1.get());
         aVec.insert(p2);
         aVec.insert(p3);
 
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1.get()) );
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(2), aVec.size() );
 
         aVec.erase(1);
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.size() );
 
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p4.get()) );
 
         aVec.clear();
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.size() );
 
-        aVec.insert(p1);
+        aVec.insert(p1.get());
         aVec.insert(p2);
         aVec.insert(p3);
         aVec.insert(p1_2);
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(4), aVec.size() );
-        aVec.insert(p1_3);
+        aVec.insert(p1_3.get());
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(5), aVec.size() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1) );
-        CPPUNIT_ASSERT( bool(aVec.find(p1) == aVec.end()) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1.get()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p1.get()) == aVec.end()) );
         CPPUNIT_ASSERT( aVec.find(p1_2) != aVec.end() );
-        CPPUNIT_ASSERT( aVec.find(p1_3) != aVec.end() );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1_3) );
-        CPPUNIT_ASSERT( bool(aVec.find(p1) == aVec.end()) );
+        CPPUNIT_ASSERT( aVec.find(p1_3.get()) != aVec.end() );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(1), aVec.erase(p1_3.get()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p1.get()) == aVec.end()) );
         CPPUNIT_ASSERT( aVec.find(p1_2) != aVec.end() );
-        CPPUNIT_ASSERT( bool(aVec.find(p1_3) == aVec.end()) );
-        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p1_3) );
-        CPPUNIT_ASSERT( bool(aVec.find(p1) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p1_3.get()) == aVec.end()) );
+        CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.erase(p1_3.get()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p1.get()) == aVec.end()) );
         CPPUNIT_ASSERT( aVec.find(p1_2) != aVec.end() );
-        CPPUNIT_ASSERT( bool(aVec.find(p1_3) == aVec.end()) );
+        CPPUNIT_ASSERT( bool(aVec.find(p1_3.get()) == aVec.end()) );
 
         aVec.DeleteAndDestroyAll();
         CPPUNIT_ASSERT_EQUAL( static_cast<size_t>(0), aVec.size() );
-        delete p1;
-        delete p1_3;
-        delete p4;
     }
 
 
diff --git a/registry/source/reflwrit.cxx b/registry/source/reflwrit.cxx
index e0b52b0..ced5726 100644
--- a/registry/source/reflwrit.cxx
+++ b/registry/source/reflwrit.cxx
@@ -877,7 +877,7 @@ void TypeWriter::createBlop()
 
     if (m_methodCount)
     {
-        sal_uInt16* pMethodEntrySize = new sal_uInt16[m_methodCount];
+        std::unique_ptr<sal_uInt16[]> pMethodEntrySize( new sal_uInt16[m_methodCount] );
         sal_uInt16  cpIndexName = 0;
         sal_uInt16  cpIndexReturn = 0;
         sal_uInt16  cpIndexDoku2 = 0;
@@ -985,8 +985,6 @@ void TypeWriter::createBlop()
                 cpIndexName = 0;
             }
         }
-
-        delete[] pMethodEntrySize;
     }
 
     // reference blop
diff --git a/registry/source/regimpl.cxx b/registry/source/regimpl.cxx
index 6f684e1..c6ea42c 100644
--- a/registry/source/regimpl.cxx
+++ b/registry/source/regimpl.cxx
@@ -1483,12 +1483,11 @@ RegError ORegistry::dumpValue(const OUString& sPath, const OUString& sName, sal_
                     sal::static_int_cast< unsigned long >(valueSize));
                 fprintf(stdout, "%s       Data = ", indent);
 
-                sal_Unicode* value = new sal_Unicode[size];
-                readString(pBuffer, value, size);
+                std::unique_ptr<sal_Unicode[]> value(new sal_Unicode[size]);
+                readString(pBuffer, value.get(), size);
 
-                OString uStr = OUStringToOString(value, RTL_TEXTENCODING_UTF8);
+                OString uStr = OUStringToOString(value.get(), RTL_TEXTENCODING_UTF8);
                 fprintf(stdout, "L\"%s\"\n", uStr.getStr());
-                delete[] value;
             }
             break;
         case RegValueType::BINARY:
diff --git a/sal/qa/osl/process/osl_Thread.cxx b/sal/qa/osl/process/osl_Thread.cxx
index 58d916e..463096e 100644
--- a/sal/qa/osl/process/osl_Thread.cxx
+++ b/sal/qa/osl/process/osl_Thread.cxx
@@ -28,17 +28,14 @@
 // include files
 
 #include <sal/types.h>
-
 #include <rtl/string.hxx>
-
 #include <rtl/strbuf.hxx>
-
 #include <osl/thread.hxx>
-
 #include <osl/mutex.hxx>
 #include <osl/time.h>
 
 #include <string.h>
+#include <memory>
 
 #include <cppunit/TestFixture.h>
 #include <cppunit/extensions/HelperMacros.h>
@@ -1694,13 +1691,12 @@ public:
 private:
     void SAL_CALL run() override
         {
-            oslThreadIdentifier* pId = new oslThreadIdentifier;
+            std::unique_ptr<oslThreadIdentifier> pId( new oslThreadIdentifier );
             *pId = getIdentifier();
-            idData.setData(pId);
+            idData.setData(pId.get());
             oslThreadIdentifier* pIdData = static_cast<oslThreadIdentifier*>(idData.getData());
             //t_print("Thread %d has Data %d\n", getIdentifier(), *pIdData);
             m_Id = *pIdData;
-            delete pId;
         }
 
 public:
diff --git a/sal/qa/rtl/oustring/rtl_OUString2.cxx b/sal/qa/rtl/oustring/rtl_OUString2.cxx
index 0fb7a09..5c00a4c 100644
--- a/sal/qa/rtl/oustring/rtl_OUString2.cxx
+++ b/sal/qa/rtl/oustring/rtl_OUString2.cxx
@@ -893,9 +893,7 @@ public:
         // Test interning lots of things
         int i;
         static const int nSequence = 4096;
-        rtl::OUString *pStrs;
-
-        pStrs = new rtl::OUString[nSequence];
+        std::unique_ptr<rtl::OUString[]> pStrs(new rtl::OUString[nSequence]);
         for (i = 0; i < nSequence; i++)
         {
             pStrs[i] = rtl::OUString::number( sqrt( static_cast<double>(i) ) ).intern();
@@ -906,7 +904,6 @@ public:
             CPPUNIT_ASSERT_EQUAL_MESSAGE("double intern failed",
                                    pStrs[i].pData, aNew.pData);
         }
-        delete [] pStrs;
     }
 
     CPPUNIT_TEST_SUITE(construction);
diff --git a/sal/qa/rtl/process/rtl_Process.cxx b/sal/qa/rtl/process/rtl_Process.cxx
index 7101bad..5901529 100644
--- a/sal/qa/rtl/process/rtl_Process.cxx
+++ b/sal/qa/rtl/process/rtl_Process.cxx
@@ -119,11 +119,11 @@ public:
         //     "osl_joinProcess returned with failure",
         //     osl_Process_E_None == osl_error
         // );
-    oslProcessInfo* pInfo = new oslProcessInfo;
+    std::unique_ptr<oslProcessInfo> pInfo( new oslProcessInfo );
     //please pay attention to initial the Size to sizeof(oslProcessInfo), or else
     //you will get unknown error when call osl_getProcessInfo
     pInfo->Size = sizeof(oslProcessInfo);
-    osl_error = osl_getProcessInfo( hProcess, osl_Process_EXITCODE, pInfo );
+    osl_error = osl_getProcessInfo( hProcess, osl_Process_EXITCODE, pInfo.get() );
     CPPUNIT_ASSERT_EQUAL_MESSAGE
         (
             "osl_getProcessInfo returned with failure",
@@ -132,7 +132,6 @@ public:
 
     printf("the exit code is %" SAL_PRIuUINT32 ".\n", pInfo->Code );
     CPPUNIT_ASSERT_EQUAL_MESSAGE("rtl_getAppCommandArg or rtl_getAppCommandArgCount error.", static_cast<oslProcessExitCode>(2), pInfo->Code);
-    delete pInfo;
     }
 
     CPPUNIT_TEST_SUITE(getAppCommandArg);
diff --git a/sal/qa/rtl/random/rtl_random.cxx b/sal/qa/rtl/random/rtl_random.cxx
index a9ecf9e..f537c7c 100644
--- a/sal/qa/rtl/random/rtl_random.cxx
+++ b/sal/qa/rtl/random/rtl_random.cxx
@@ -98,8 +98,8 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 4;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
-        memset(pBuffer, 0, nBufLen);
+        std::unique_ptr<sal_uInt8[]>  pBuffer( new sal_uInt8[ nBufLen ] );
+        memset(pBuffer.get(), 0, nBufLen);
 
         rtlRandomError aError = rtl_random_addBytes(nullptr, nullptr, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_Argument, aError);
@@ -107,12 +107,10 @@ public:
         /* rtlRandomError */ aError = rtl_random_addBytes(aPool, nullptr, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_Argument, aError);
 
-        /* rtlRandomError */ aError = rtl_random_addBytes(aPool, pBuffer, nBufLen);
+        /* rtlRandomError */ aError = rtl_random_addBytes(aPool, pBuffer.get(), nBufLen);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_None, aError);
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
-
     }
 
     void addBytes_001()
@@ -120,16 +118,15 @@ public:
             rtlRandomPool aPool = rtl_random_createPool();
 
             sal_uInt32  nBufLen = 4;
-            sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
+            std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nBufLen ] );
 
-            memset(pBuffer, 0, nBufLen);
+            memset(pBuffer.get(), 0, nBufLen);
 
-            rtl_random_addBytes(aPool, pBuffer, nBufLen);
+            rtl_random_addBytes(aPool, pBuffer.get(), nBufLen);
 
             printf("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
 
             rtl_random_destroyPool(aPool);
-            delete [] pBuffer;
         }
 
     // Change the following lines only, if you add, remove or rename
@@ -220,8 +217,8 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 4;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
-        memset(pBuffer, 0, nBufLen);
+        std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nBufLen ] );
+        memset(pBuffer.get(), 0, nBufLen);
 
         rtlRandomError aError = rtl_random_getBytes(nullptr, nullptr, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_Argument, aError);
@@ -229,11 +226,10 @@ public:
         /* rtlRandomError */ aError = rtl_random_getBytes(aPool, nullptr, 0);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_Argument, aError);
 
-        /* rtlRandomError */ aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
+        /* rtlRandomError */ aError = rtl_random_getBytes(aPool, pBuffer.get(), nBufLen);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_None, aError);
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
     }
 
     void getBytes_001()
@@ -241,16 +237,15 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 4;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
-        memset(pBuffer, 0, nBufLen);
+        std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nBufLen ] );
+        memset(pBuffer.get(), 0, nBufLen);
 
-        rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
+        rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer.get(), nBufLen);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_None, aError);
 
         printf("%2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3]);
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
     }
 
     void getBytes_002()
@@ -258,12 +253,12 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 4;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen << 1 ];
-        memset(pBuffer, 0, nBufLen << 1);
+        std::unique_ptr<sal_uInt8[]>  pBuffer( new sal_uInt8[ nBufLen << 1 ] );
+        memset(pBuffer.get(), 0, nBufLen << 1);
 
         CPPUNIT_ASSERT_MESSAGE("memset failed", pBuffer[4] == 0 && pBuffer[5] == 0 && pBuffer[6] == 0 && pBuffer[7] == 0);
 
-        rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer, nBufLen);
+        rtlRandomError aError = rtl_random_getBytes(aPool, pBuffer.get(), nBufLen);
         CPPUNIT_ASSERT_EQUAL_MESSAGE("wrong parameter", rtl_Random_E_None, aError);
 
         printf("%2x %2x %2x %2x %2x %2x %2x %2x\n", pBuffer[0], pBuffer[1], pBuffer[2], pBuffer[3], pBuffer[4], pBuffer[5], pBuffer[6], pBuffer[7]);
@@ -271,7 +266,6 @@ public:
         CPPUNIT_ASSERT_MESSAGE("internal memory overwrite", pBuffer[4] == 0 && pBuffer[5] == 0 && pBuffer[6] == 0 && pBuffer[7] == 0);
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
     }
 
     void getBytes_003()
@@ -279,8 +273,8 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 1;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
-        memset(pBuffer, 0, nBufLen);
+        std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nBufLen ] );
+        memset(pBuffer.get(), 0, nBufLen);
 
         Statistics aStat;
 
@@ -291,7 +285,7 @@ public:
         int nCountMax = 1000000;
         for(nCount = 0;nCount < nCountMax; ++nCount)                  // run 100000000 through getBytes(...)
         {
-            /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
+            /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer.get(), nBufLen);
             /* CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None); */
 
             aStat.addValue(pBuffer[0], 1);
@@ -303,7 +297,6 @@ public:
         CPPUNIT_ASSERT_MESSAGE("deviation should be less average", aStat.getMaxDeviation() < aStat.getAverage());
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
     }
 
     void getBytes_003_1()
@@ -311,8 +304,8 @@ public:
         rtlRandomPool aPool = rtl_random_createPool();
 
         sal_uInt32  nBufLen = 256;
-        sal_uInt8   *pBuffer = new sal_uInt8[ nBufLen ];
-        memset(pBuffer, 0, nBufLen);
+        std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nBufLen ] );
+        memset(pBuffer.get(), 0, nBufLen);
 
         Statistics aStat;
 
@@ -323,7 +316,7 @@ public:
         int nCountMax = 10000;
         for(nCount = 0;nCount < nCountMax; ++nCount)                  // run 100000000 through getBytes(...)
         {
-            /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer, nBufLen);
+            /* rtlRandomError aError = */ rtl_random_getBytes(aPool, pBuffer.get(), nBufLen);
             // CPPUNIT_ASSERT_MESSAGE("wrong parameter", aError == rtl_Random_E_None);
 
             for (sal_uInt32 i=0;i<nBufLen;++i)
@@ -336,7 +329,6 @@ public:
         CPPUNIT_ASSERT_MESSAGE("deviation should be less average", aStat.getMaxDeviation() < aStat.getAverage());
 
         rtl_random_destroyPool(aPool);
-        delete [] pBuffer;
     }
 
     // Change the following lines only, if you add, remove or rename
diff --git a/sc/source/core/tool/chartpos.cxx b/sc/source/core/tool/chartpos.cxx
index ad16dcf..f4bd0c8 100644
--- a/sc/source/core/tool/chartpos.cxx
+++ b/sc/source/core/tool/chartpos.cxx
@@ -358,7 +358,7 @@ void ScChartPositioner::CreatePositionMap()
     GlueState();
 
     const bool bNoGlue = (eGlue == ScChartGlue::NONE);
-    ColumnMap* pCols = new ColumnMap;
+    std::unique_ptr<ColumnMap> pCols( new ColumnMap );
     SCROW nNoGlueRow = 0;
     for ( size_t i = 0, nRanges = aRangeListRef->size(); i < nRanges; ++i )
     {
@@ -464,7 +464,6 @@ void ScChartPositioner::CreatePositionMap()
     {   // Only delete tables, not the ScAddress*!
         delete it->second;
     }
-    delete pCols;
 }
 
 void ScChartPositioner::InvalidateGlue()
diff --git a/sc/source/core/tool/rangeutl.cxx b/sc/source/core/tool/rangeutl.cxx
index 8a2e14a..263c7bc 100644
--- a/sc/source/core/tool/rangeutl.cxx
+++ b/sc/source/core/tool/rangeutl.cxx
@@ -539,20 +539,16 @@ bool ScRangeStringConverter::GetRangeListFromString(
     sal_Int32 nOffset = 0;
     while( nOffset >= 0 )
     {
-        ScRange* pRange = new ScRange;
+        std::unique_ptr<ScRange> pRange( new ScRange );
         if (
              GetRangeFromString( *pRange, rRangeListStr, pDocument, eConv, nOffset, cSeparator, cQuote ) &&
              (nOffset >= 0)
            )
         {
-            rRangeList.push_back( pRange );
-            pRange = nullptr;
+            rRangeList.push_back( pRange.release() );
         }
         else if (nOffset > -1)
             bRet = false;
-        //if ownership transferred to rRangeList pRange was NULLed, otherwwise
-        //delete it
-        delete pRange;
     }
     return bRet;
 }
diff --git a/sc/source/filter/rtf/eeimpars.cxx b/sc/source/filter/rtf/eeimpars.cxx
index 48158d9..ad68893 100644
--- a/sc/source/filter/rtf/eeimpars.cxx
+++ b/sc/source/filter/rtf/eeimpars.cxx
@@ -106,8 +106,8 @@ sal_uLong ScEEImport::Read( SvStream& rStream, const OUString& rBaseURL )
 
 void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNumberFormatter* pFormatter, bool bConvertDate )
 {
-    ScProgress* pProgress = new ScProgress( mpDoc->GetDocumentShell(),
-        ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->ListSize(), true );
+    std::unique_ptr<ScProgress> pProgress( new ScProgress( mpDoc->GetDocumentShell(),
+        ScGlobal::GetRscString( STR_LOAD_DOC ), mpParser->ListSize(), true ) );
     sal_uLong nProgress = 0;
 
     SCCOL nStartCol, nEndCol;
@@ -438,7 +438,7 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
                 pProgress->SetState( ++nProgress );
             }
         }
-        DELETEZ( pProgress ); // SetOptimalHeight has its own ProgressBar
+        pProgress.reset(); // SetOptimalHeight has its own ProgressBar
         // Adjust line height, base is 100% zoom
         Fraction aZoom( 1, 1 );
         // Factor is printer to display ratio
@@ -475,7 +475,6 @@ void ScEEImport::WriteToDocument( bool bSizeColsRows, double nOutputFactor, SvNu
             }
         }
     }
-    delete pProgress;
 }
 
 bool ScEEImport::GraphicSize( SCCOL nCol, SCROW nRow, SCTAB /*nTab*/, ScEEParseEntry* pE )
diff --git a/sc/source/ui/view/formatsh.cxx b/sc/source/ui/view/formatsh.cxx
index 1d81306..f0d0976 100644
--- a/sc/source/ui/view/formatsh.cxx
+++ b/sc/source/ui/view/formatsh.cxx
@@ -1175,7 +1175,7 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
                 {
                     OUString aCode = static_cast<const SfxStringItem*>(pItem)->GetValue();
                     sal_uInt16 aLen = aCode.getLength();
-                    OUString* sFormat = new OUString[4];
+                    std::unique_ptr<OUString[]> sFormat( new OUString[4] );
                     OUString sTmpStr = "";
                     sal_uInt16 nCount(0);
                     sal_uInt16 nStrCount(0);
@@ -1214,7 +1214,6 @@ void ScFormatShell::ExecuteNumFormat( SfxRequest& rReq )
                         nPrecision,
                         nLeadZeroes);
                     pTabViewShell->SetNumFmtByStr(aCode);
-                    delete[] sFormat;
                 }
             }
             break;
diff --git a/sccomp/source/solver/LpsolveSolver.cxx b/sccomp/source/solver/LpsolveSolver.cxx
index d517696..114a259 100644
--- a/sccomp/source/solver/LpsolveSolver.cxx
+++ b/sccomp/source/solver/LpsolveSolver.cxx
@@ -218,7 +218,7 @@ void SAL_CALL LpsolveSolver::solve()
             table::CellAddress aLeftAddr = maConstraints[nConstrPos].Left;
 
             const std::vector<double>& rLeftCoeff = aCellsHash[aLeftAddr];
-            REAL* pValues = new REAL[nVariables+1];
+            std::unique_ptr<REAL[]> pValues(new REAL[nVariables+1] );
             pValues[0] = 0.0;                               // ignored?
             for (nVar=0; nVar<nVariables; nVar++)
                 pValues[nVar+1] = rLeftCoeff[nVar+1];
@@ -247,9 +247,7 @@ void SAL_CALL LpsolveSolver::solve()
                 default:
                     OSL_FAIL( "unexpected enum type" );
             }
-            add_constraint( lp, pValues, nConstrType, fRightValue );
-
-            delete[] pValues;
+            add_constraint( lp, pValues.get(), nConstrType, fRightValue );
         }
     }
 
diff --git a/scripting/source/stringresource/stringresource.cxx b/scripting/source/stringresource/stringresource.cxx
index 190fabd..e21cf06 100644
--- a/scripting/source/stringresource/stringresource.cxx
+++ b/scripting/source/stringresource/stringresource.cxx
@@ -1511,7 +1511,7 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >&
     sal_Int32 iDefault = aIn.readInt16();
     (void)iDefault;
 
-    sal_Int32* pPositions = new sal_Int32[nLocaleCount + 1];
+    std::unique_ptr<sal_Int32[]> pPositions( new sal_Int32[nLocaleCount + 1] );
     for( sal_Int32 i = 0; i < nLocaleCount + 1; i++ )
         pPositions[i] = aIn.readInt32();
 
@@ -1542,8 +1542,6 @@ void StringResourcePersistenceImpl::importBinary( const Sequence< ::sal_Int8 >&
 
     if( pUseAsDefaultItem != nullptr )
         setDefaultLocale( pUseAsDefaultItem->m_locale );
-
-    delete[] pPositions;
 }
 
 
@@ -2106,7 +2104,7 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale
         sal_Int32 nTabSize = nMaxIndex - nMinIndex + 1;
 
         // Create sorted array of pointers to the id strings
-        const OUString** pIdPtrs = new const OUString*[nTabSize];
+        std::unique_ptr<const OUString*[]> pIdPtrs( new const OUString*[nTabSize] );
         for(sal_Int32 i = 0 ; i < nTabSize ; i++ )
             pIdPtrs[i] = nullptr;
         for( it_index = rIndexMap.begin(); it_index != rIndexMap.end(); ++it_index )
@@ -2132,8 +2130,6 @@ bool StringResourcePersistenceImpl::implWritePropertiesFile( LocaleItem* pLocale
                 }
             }
         }
-
-        delete[] pIdPtrs;
     }
 
     bSuccess = true;
diff --git a/sd/source/filter/eppt/pptexsoundcollection.cxx b/sd/source/filter/eppt/pptexsoundcollection.cxx
index 2027ff3..24ee032 100644
--- a/sd/source/filter/eppt/pptexsoundcollection.cxx
+++ b/sd/source/filter/eppt/pptexsoundcollection.cxx
@@ -129,16 +129,15 @@ void ExSoundEntry::Write( SvStream& rSt, sal_uInt32 nId ) const
         SvStream* pSourceFile = ::utl::UcbStreamHelper::CreateStream( aSoundURL, StreamMode::READ );
         if ( pSourceFile )
         {
-            sal_uInt8* pBuf = new sal_uInt8[ 0x10000 ];   // 64 kB  Buffer
+            std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ 0x10000 ] );   // 64 kB  Buffer
             while ( nBytesLeft )
             {
                 sal_uInt32 nToDo = ( nBytesLeft > 0x10000 ) ? 0x10000 : nBytesLeft;
-                pSourceFile->ReadBytes(pBuf, nToDo);
-                rSt.WriteBytes(pBuf, nToDo);
+                pSourceFile->ReadBytes(pBuf.get(), nToDo);
+                rSt.WriteBytes(pBuf.get(), nToDo);
                 nBytesLeft -= nToDo;
             }
             delete pSourceFile;
-            delete[] pBuf;
         }
     }
     catch( css::uno::Exception& )
diff --git a/sd/source/filter/ppt/pptin.cxx b/sd/source/filter/ppt/pptin.cxx
index 0679a1e..cb32839 100644
--- a/sd/source/filter/ppt/pptin.cxx
+++ b/sd/source/filter/ppt/pptin.cxx
@@ -1951,14 +1951,14 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
 
                             aGalleryUserSound.Append( aRetval );
                             sal_uInt32 nSoundDataLen = aSoundDataRecHd.nRecLen;
-                            sal_uInt8* pBuf = new sal_uInt8[ nSoundDataLen ];
+                            std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nSoundDataLen ] );
 
-                            rStCtrl.ReadBytes(pBuf, nSoundDataLen);
+                            rStCtrl.ReadBytes(pBuf.get(), nSoundDataLen);
                             SvStream* pOStm = ::utl::UcbStreamHelper::CreateStream( aGalleryUserSound.GetMainURL( INetURLObject::DecodeMechanism::NONE ), StreamMode::WRITE | StreamMode::TRUNC );
 
                             if( pOStm )
                             {
-                                pOStm->WriteBytes(pBuf, nSoundDataLen);
+                                pOStm->WriteBytes(pBuf.get(), nSoundDataLen);
 
                                 if( pOStm->GetError() == ERRCODE_NONE )
                                 {
@@ -1968,8 +1968,6 @@ OUString ImplSdPPTImport::ReadSound(sal_uInt32 nSoundRef) const
 
                                 delete pOStm;
                             }
-
-                            delete[] pBuf;
                         }
                     }
                 }
diff --git a/sd/source/filter/ppt/propread.cxx b/sd/source/filter/ppt/propread.cxx
index 2167bda..d567b2c 100644
--- a/sd/source/filter/ppt/propread.cxx
+++ b/sd/source/filter/ppt/propread.cxx
@@ -104,13 +104,13 @@ bool PropItem::Read( OUString& rString, sal_uInt32 nStringType, bool bAlign )
             {
                 try
                 {
-                    sal_Char* pString = new sal_Char[ nItemSize ];
+                    std::unique_ptr<sal_Char[]> pString( new sal_Char[ nItemSize ] );
                     if ( mnTextEnc == RTL_TEXTENCODING_UCS2 )
                     {
                         nItemSize >>= 1;
                         if ( nItemSize > 1 )
                         {
-                            sal_Unicode* pWString = reinterpret_cast<sal_Unicode*>(pString);
+                            sal_Unicode* pWString = reinterpret_cast<sal_Unicode*>(pString.get());
                             for (sal_uInt32 i = 0; i < nItemSize; ++i)
                                 ReadUtf16( pWString[ i ] );
                             rString = OUString(pWString, lcl_getMaxSafeStrLen(nItemSize));
@@ -121,17 +121,16 @@ bool PropItem::Read( OUString& rString, sal_uInt32 nStringType, bool bAlign )
                     }
                     else
                     {
-                        SvMemoryStream::ReadBytes(pString, nItemSize);
+                        SvMemoryStream::ReadBytes(pString.get(), nItemSize);
                         if ( pString[ nItemSize - 1 ] == 0 )
                         {
                             if ( nItemSize > 1 )
-                                rString = OUString(pString, rtl_str_getLength(pString), mnTextEnc);
+                                rString = OUString(pString.get(), rtl_str_getLength(pString.get()), mnTextEnc);
                             else
                                 rString.clear();
                             bRetValue = true;
                         }
                     }
-                    delete[] pString;
                 }
                 catch( const std::bad_alloc& )
                 {
@@ -159,18 +158,17 @@ bool PropItem::Read( OUString& rString, sal_uInt32 nStringType, bool bAlign )
             {
                 try
                 {
-                    sal_Unicode* pString = new sal_Unicode[ nItemSize ];
+                    std::unique_ptr<sal_Unicode[]> pString( new sal_Unicode[ nItemSize ] );
                     for (sal_uInt32 i = 0; i < nItemSize; ++i)
                         ReadUtf16( pString[ i ] );
                     if ( pString[ nItemSize - 1 ] == 0 )
                     {
                         if ( (sal_uInt16)nItemSize > 1 )
-                            rString = OUString(pString, lcl_getMaxSafeStrLen(nItemSize));
+                            rString = OUString(pString.get(), lcl_getMaxSafeStrLen(nItemSize));
                         else
                             rString.clear();
                         bRetValue = true;
                     }
-                    delete[] pString;
                 }
                 catch( const std::bad_alloc& )
                 {
@@ -298,18 +296,16 @@ void Section::GetDictionary(Dictionary& rDict)
         {
             if ( mnTextEnc == RTL_TEXTENCODING_UCS2 )
             {
-                sal_Unicode* pWString = new sal_Unicode[nSize];
+                std::unique_ptr<sal_Unicode[]> pWString( new sal_Unicode[nSize] );
                 for (sal_uInt32 j = 0; j < nSize; ++j)
                     aStream.ReadUtf16(pWString[j]);
-                aString = OUString(pWString, lcl_getMaxSafeStrLen(nSize));
-                delete[] pWString;
+                aString = OUString(pWString.get(), lcl_getMaxSafeStrLen(nSize));
             }
             else
             {
-                sal_Char* pString = new sal_Char[nSize];
-                aStream.ReadBytes(pString, nSize);
-                aString = OUString(pString, lcl_getMaxSafeStrLen(nSize), mnTextEnc);
-                delete[] pString;
+                std::unique_ptr<sal_Char[]> pString( new sal_Char[nSize] );
+                aStream.ReadBytes(pString.get(), nSize);
+                aString = OUString(pString.get(), lcl_getMaxSafeStrLen(nSize), mnTextEnc);
             }
         }
         catch( const std::bad_alloc& )
@@ -456,10 +452,9 @@ void Section::Read( SotStorageStream *pStrm )
                 // make sure we don't overflow the section size
                 if( nPropSize > nSecSize - nSecOfs )
                     nPropSize = nSecSize - nSecOfs;
-                sal_uInt8* pBuf = new sal_uInt8[ nPropSize ];
-                nPropSize = pStrm->ReadBytes(pBuf, nPropSize);
-                AddProperty( nPropId, pBuf, nPropSize );
-                delete[] pBuf;
+                std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nPropSize ] );
+                nPropSize = pStrm->ReadBytes(pBuf.get(), nPropSize);
+                AddProperty( nPropId, pBuf.get(), nPropSize );
             }
             if ( nPropId == 1 )
             {
@@ -517,10 +512,9 @@ void Section::Read( SotStorageStream *pStrm )
             {
                 break;
             }
-            sal_uInt8* pBuf = new sal_uInt8[ nSize ];
-            nSize = pStrm->ReadBytes(pBuf, nSize);
-            AddProperty( 0xffffffff, pBuf, nSize );
-            delete[] pBuf;
+            std::unique_ptr<sal_uInt8[]> pBuf( new sal_uInt8[ nSize ] );
+            nSize = pStrm->ReadBytes(pBuf.get(), nSize);
+            AddProperty( 0xffffffff, pBuf.get(), nSize );
         }
         pStrm->Seek(nCurrent);
     }
@@ -581,7 +575,7 @@ void PropRead::Read()
         mpSvStream->ReadUInt16( mnByteOrder ).ReadUInt16( mnFormat ).ReadUInt16( mnVersionLo ).ReadUInt16( mnVersionHi );
         if ( mnByteOrder == 0xfffe )
         {
-            sal_uInt8*  pSectCLSID = new sal_uInt8[ 16 ];
+            std::unique_ptr<sal_uInt8[]> pSectCLSID( new sal_uInt8[ 16 ] );
             mpSvStream->ReadBytes(mApplicationCLSID, 16);
             mpSvStream->ReadUInt32( nSections );
             if ( nSections > 2 )                // sj: PowerPoint documents are containing max 2 sections
@@ -590,16 +584,15 @@ void PropRead::Read()
             }
             else for ( sal_uInt32 i = 0; i < nSections; i++ )
             {
-                mpSvStream->ReadBytes(pSectCLSID, 16);
+                mpSvStream->ReadBytes(pSectCLSID.get(), 16);
                 mpSvStream->ReadUInt32( nSectionOfs );
                 nCurrent = mpSvStream->Tell();
                 mpSvStream->Seek( nSectionOfs );
-                Section aSection( pSectCLSID );
+                Section aSection( pSectCLSID.get() );
                 aSection.Read( mpSvStream.get() );
                 maSections.push_back( o3tl::make_unique<Section>( aSection ) );
                 mpSvStream->Seek( nCurrent );
             }
-            delete[] pSectCLSID;
         }
     }
 }
diff --git a/sd/source/ui/docshell/docshel2.cxx b/sd/source/ui/docshell/docshel2.cxx
index af8320e..f43bc1a 100644
--- a/sd/source/ui/docshell/docshel2.cxx
+++ b/sd/source/ui/docshell/docshel2.cxx
@@ -52,7 +52,7 @@ void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, sal_uInt16 nAspect)
       // THUMBNAIL: here we may can set the draft mode
     }
 
-    ClientView* pView = new ClientView(this, pOut);
+    std::unique_ptr<ClientView> pView( new ClientView(this, pOut) );
 
     pView->SetHlplVisible(false);
     pView->SetGridVisible(false);
@@ -116,9 +116,6 @@ void DrawDocShell::Draw(OutputDevice* pOut, const JobSetup&, sal_uInt16 nAspect)
             pOut->SetMapMode(aOldMapMode);
         }
     }
-
-    delete pView;
-
 }
 
 Rectangle DrawDocShell::GetVisArea(sal_uInt16 nAspect) const
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 7fd6355..082d6ec 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -1895,9 +1895,9 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
                 if ( !( (mpDoc->GetSdPage((sal_Int16) nPageNumber-1, PageKind::Standard))->IsExcluded() ) ||
                     (pPDFExtOutDevData && pPDFExtOutDevData->GetIsExportHiddenSlides()) )
                 {
-                    ::sd::ClientView* pView = new ::sd::ClientView( mpDocShell, pOut );
-                    Rectangle               aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() );
-                    vcl::Region                  aRegion( aVisArea );
+                    std::unique_ptr<::sd::ClientView> pView( new ::sd::ClientView( mpDocShell, pOut ) );
+                    Rectangle                         aVisArea = Rectangle( Point(), mpDoc->GetSdPage( (sal_uInt16)nPageNumber - 1, ePageKind )->GetSize() );
+                    vcl::Region                       aRegion( aVisArea );
 
                     ::sd::ViewShell* pOldViewSh = mpDocShell->GetViewShell();
                     ::sd::View* pOldSdView = pOldViewSh ? pOldViewSh->GetView() : nullptr;
@@ -2207,8 +2207,6 @@ void SAL_CALL SdXImpressDocument::render( sal_Int32 nRenderer, const uno::Any& r
                             pView->DrawMarkedObj(*pOut);
                         }
                     }
-
-                    delete pView;
                 }
             }
         }
diff --git a/starmath/source/mathmlexport.cxx b/starmath/source/mathmlexport.cxx
index e3cad95..c313567 100644
--- a/starmath/source/mathmlexport.cxx
+++ b/starmath/source/mathmlexport.cxx
@@ -611,8 +611,8 @@ void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel)
 {
     TG nGroup = pNode->GetToken().nGroup;
 
-    SvXMLElementExport* pRow = new SvXMLElementExport(*this,
-        XML_NAMESPACE_MATH, XML_MROW, true, true);
+    std::unique_ptr<SvXMLElementExport> pRow( new SvXMLElementExport(*this,
+        XML_NAMESPACE_MATH, XML_MROW, true, true) );
 
     // Unfold the binary tree structure as long as the nodes are SmBinHorNode
     // with the same nGroup. This will reduce the number of nested <mrow>
@@ -638,8 +638,6 @@ void SmXMLExport::ExportBinaryHorizontal(const SmNode *pNode, int nLevel)
         s.push(binNode->Symbol());
         s.push(binNode->LeftOperand());
     }
-
-    delete pRow;
 }
 
 void SmXMLExport::ExportUnaryHorizontal(const SmNode *pNode, int nLevel)
@@ -707,8 +705,8 @@ void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel)
     {
         // widebslash
         // We can not use <mfrac> to a backslash, so just use <mo>\</mo>
-        SvXMLElementExport *pRow = new SvXMLElementExport(*this,
-            XML_NAMESPACE_MATH, XML_MROW, true, true);
+        std::unique_ptr<SvXMLElementExport> pRow( new SvXMLElementExport(*this,
+            XML_NAMESPACE_MATH, XML_MROW, true, true) );
 
         ExportNodes(pNode->GetSubNode(0), nLevel);
 
@@ -720,8 +718,6 @@ void SmXMLExport::ExportBinaryDiagonal(const SmNode *pNode, int nLevel)
         }
 
         ExportNodes(pNode->GetSubNode(1), nLevel);
-
-        delete pRow;
     }
 }
 
diff --git a/stoc/source/inspect/introspection.cxx b/stoc/source/inspect/introspection.cxx
index 033f2e7..3ea435b 100644
--- a/stoc/source/inspect/introspection.cxx
+++ b/stoc/source/inspect/introspection.cxx
@@ -1871,8 +1871,8 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
                         REMOVE_LISTENER_METHOD,        // remove method of a listener interface
                         INVALID_METHOD                // method whose class is not considered, e.g. XPropertySet
                     };
-                    MethodType* pMethodTypes = new MethodType[ nSourceMethodCount ];
-                    sal_Int32* pLocalMethodConcepts = new sal_Int32[ nSourceMethodCount ];
+                    std::unique_ptr<MethodType[]> pMethodTypes( new MethodType[ nSourceMethodCount ] );
+                    std::unique_ptr<sal_Int32[]> pLocalMethodConcepts( new sal_Int32[ nSourceMethodCount ] );
                     for( i = 0 ; i < nSourceMethodCount ; i++ )
                     {
                         pMethodTypes[ i ] = STANDARD_METHOD;
@@ -2354,9 +2354,6 @@ css::uno::Reference<css::beans::XIntrospectionAccess> Implementation::inspect(
                     // ignore them in the future
                     if( bFoundXInterface )
                         bXInterfaceIsInvalid = true;
-
-                    delete[] pMethodTypes;
-                    delete[] pLocalMethodConcepts;
                 }
 
                 // Do superclasses exist? Then continue here
diff --git a/svtools/source/contnr/svtabbx.cxx b/svtools/source/contnr/svtabbx.cxx
index e114d65..be8b00b 100644
--- a/svtools/source/contnr/svtabbx.cxx
+++ b/svtools/source/contnr/svtabbx.cxx
@@ -322,9 +322,8 @@ void SvTabListBox::SetEntryText(const OUString& rStr, SvTreeListEntry* pEntry, s
     }
     GetModel()->InvalidateEntry( pEntry );
 
-    TabListBoxEventData* pData = new TabListBoxEventData( pEntry, nTextColumn, sOldText );
-    CallEventListeners( VclEventId::TableCellNameChanged, pData );
-    delete pData;
+    std::unique_ptr<TabListBoxEventData> pData( new TabListBoxEventData( pEntry, nTextColumn, sOldText ) );
+    CallEventListeners( VclEventId::TableCellNameChanged, pData.get() );
 }
 
 OUString SvTabListBox::GetCellText( sal_uLong nPos, sal_uInt16 nCol ) const
diff --git a/sw/source/core/access/accfrmobjmap.cxx b/sw/source/core/access/accfrmobjmap.cxx
index 28511ab..43da30d 100644
--- a/sw/source/core/access/accfrmobjmap.cxx
+++ b/sw/source/core/access/accfrmobjmap.cxx
@@ -103,20 +103,17 @@ SwAccessibleChildMap::SwAccessibleChildMap( const SwRect& rVisArea,
                 if ( pAccImpl &&
                      pAccImpl->HasAdditionalAccessibleChildren() )
                 {
-                    std::vector< vcl::Window* >* pAdditionalChildren =
-                                                new std::vector< vcl::Window* >();
-                    pAccImpl->GetAdditionalAccessibleChildren( pAdditionalChildren );
+                    std::vector< vcl::Window* > aAdditionalChildren;
+                    pAccImpl->GetAdditionalAccessibleChildren( &aAdditionalChildren );
 
                     sal_Int32 nCounter( 0 );
-                    for ( std::vector< vcl::Window* >::iterator aIter = pAdditionalChildren->begin();
-                          aIter != pAdditionalChildren->end();
+                    for ( std::vector< vcl::Window* >::iterator aIter = aAdditionalChildren.begin();
+                          aIter != aAdditionalChildren.end();
                           ++aIter )
                     {
                         aLower = (*aIter);
                         insert( ++nCounter, SwAccessibleChildMapKey::XWINDOW, aLower );
                     }
-
-                    delete pAdditionalChildren;
                 }
             }
         }
diff --git a/sw/source/core/access/accpara.cxx b/sw/source/core/access/accpara.cxx
index 624928a..fa4913f 100644
--- a/sw/source/core/access/accpara.cxx
+++ b/sw/source/core/access/accpara.cxx
@@ -1922,15 +1922,12 @@ void SwAccessibleParagraph::_getRunAttributesImpl(
     SwPaM* pPaM( nullptr );
     {
         const SwTextNode* pTextNode( GetTextNode() );
-        SwPosition* pStartPos = new SwPosition( *pTextNode );
+        std::unique_ptr<SwPosition> pStartPos( new SwPosition( *pTextNode ) );
         pStartPos->nContent.Assign( const_cast<SwTextNode*>(pTextNode), nIndex );
-        SwPosition* pEndPos = new SwPosition( *pTextNode );
+        std::unique_ptr<SwPosition> pEndPos( new SwPosition( *pTextNode ) );
         pEndPos->nContent.Assign( const_cast<SwTextNode*>(pTextNode), nIndex+1 );
 
         pPaM = new SwPaM( *pStartPos, *pEndPos );
-
-        delete pStartPos;
-        delete pEndPos;
     }
 
     // retrieve character attributes for the created PaM <pPaM>
diff --git a/sw/source/core/crsr/crsrsh.cxx b/sw/source/core/crsr/crsrsh.cxx
index 4b1d6b7..5d2b999 100644
--- a/sw/source/core/crsr/crsrsh.cxx
+++ b/sw/source/core/crsr/crsrsh.cxx
@@ -2585,7 +2585,7 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
     SwNode *pNode = &rIdx.GetNode();
 
     // create a new PaM
-    SwPaM * pNew = new SwPaM( *GetCursor()->GetPoint() );
+    std::unique_ptr<SwPaM> pNew( new SwPaM( *GetCursor()->GetPoint() ) );
     if( pNode->GetStartNode() )
     {
         if( ( pNode = pNode->StartOfSectionNode())->IsTableNode() )
@@ -2612,9 +2612,9 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
         {
             SwCursorShell* pSh = static_cast<SwCursorShell*>(&rTmp);
             if( pSh->m_pCursorStack )
-                pSh->ParkPams( pNew, &pSh->m_pCursorStack );
+                pSh->ParkPams( pNew.get(), &pSh->m_pCursorStack );
 
-            pSh->ParkPams( pNew, &pSh->m_pCurrentCursor );
+            pSh->ParkPams( pNew.get(), &pSh->m_pCurrentCursor );
             if( pSh->m_pTableCursor )
             {
                 // set table cursor always to 0 and the current one always to
@@ -2629,7 +2629,6 @@ void SwCursorShell::ParkCursor( const SwNodeIndex &rIdx )
             }
         }
     }
-    delete pNew;
 }
 
 /** Copy constructor
diff --git a/sw/source/core/doc/doccomp.cxx b/sw/source/core/doc/doccomp.cxx
index 7cef79e..5adbb5f 100644
--- a/sw/source/core/doc/doccomp.cxx
+++ b/sw/source/core/doc/doccomp.cxx
@@ -588,8 +588,8 @@ Compare::Compare( sal_uLong nDiff, CompareData& rData1, CompareData& rData2 )
     MovedData *pMD1, *pMD2;
     // Look for the differing lines
     {
-        sal_Char* pDiscard1 = new sal_Char[ rData1.GetLineCount() ];
-        sal_Char* pDiscard2 = new sal_Char[ rData2.GetLineCount() ];
+        std::unique_ptr<sal_Char[]> pDiscard1( new sal_Char[ rData1.GetLineCount() ] );
+        std::unique_ptr<sal_Char[]> pDiscard2( new sal_Char[ rData2.GetLineCount() ] );
 
         sal_uLong* pCount1 = new sal_uLong[ nDiff ];
         sal_uLong* pCount2 = new sal_uLong[ nDiff ];
@@ -602,20 +602,17 @@ Compare::Compare( sal_uLong nDiff, CompareData& rData1, CompareData& rData2 )
 
         // All which occur only once now have either been inserted or deleted.
         // All which are also contained in the other one have been moved.
-        SetDiscard( rData1, pDiscard1, pCount2 );
-        SetDiscard( rData2, pDiscard2, pCount1 );
+        SetDiscard( rData1, pDiscard1.get(), pCount2 );
+        SetDiscard( rData2, pDiscard2.get(), pCount1 );
 
         // forget the arrays again
         delete [] pCount1; delete [] pCount2;
 
-        CheckDiscard( rData1.GetLineCount(), pDiscard1 );
-        CheckDiscard( rData2.GetLineCount(), pDiscard2 );
+        CheckDiscard( rData1.GetLineCount(), pDiscard1.get() );
+        CheckDiscard( rData2.GetLineCount(), pDiscard2.get() );
 
-        pMD1 = new MovedData( rData1, pDiscard1 );
-        pMD2 = new MovedData( rData2, pDiscard2 );
-
-        // forget the arrays again
-        delete [] pDiscard1; delete [] pDiscard2;
+        pMD1 = new MovedData( rData1, pDiscard1.get() );
+        pMD2 = new MovedData( rData2, pDiscard2.get() );
     }
 
     {
diff --git a/sw/source/core/frmedt/fecopy.cxx b/sw/source/core/frmedt/fecopy.cxx
index dc95e72..18678ce 100644
--- a/sw/source/core/frmedt/fecopy.cxx
+++ b/sw/source/core/frmedt/fecopy.cxx
@@ -1317,14 +1317,14 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
     StartUndo();
 
     SvtPathOptions aPathOpt;
-    FmFormModel* pModel = new FmFormModel( aPathOpt.GetPalettePath(),
-                                            nullptr, GetDoc()->GetDocShell() );
+    std::unique_ptr<FmFormModel> pModel( new FmFormModel( aPathOpt.GetPalettePath(),
+                                            nullptr, GetDoc()->GetDocShell() ) );
     pModel->GetItemPool().FreezeIdRanges();
 
     rStrm.Seek(0);
 
     uno::Reference< io::XInputStream > xInputStream( new utl::OInputStreamWrapper( rStrm ) );
-    SvxDrawingLayerImport( pModel, xInputStream );
+    SvxDrawingLayerImport( pModel.get(), xInputStream );
 
     if ( !Imp()->HasDrawView() )
         Imp()->MakeDrawView();
@@ -1496,7 +1496,7 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
 
         // #i50824#
         // method <lcl_RemoveOleObjsFromSdrModel> replaced by <lcl_ConvertSdrOle2ObjsToSdrGrafObjs>
-        lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel );
+        lcl_ConvertSdrOle2ObjsToSdrGrafObjs( pModel.get() );
         pView->Paste(*pModel, aPos, nullptr, SdrInsertFlags::NONE);
 
         const size_t nCnt = pView->GetMarkedObjectList().GetMarkCount();
@@ -1530,7 +1530,6 @@ void SwFEShell::Paste( SvStream& rStrm, SwPasteSdr nAction, const Point* pPt )
     }
     EndUndo();
     EndAllAction();
-    delete pModel;
 }
 
 bool SwFEShell::Paste(const Graphic &rGrf, const OUString& rURL)
diff --git a/sw/source/core/layout/paintfrm.cxx b/sw/source/core/layout/paintfrm.cxx
index 90c1f3b..27c722b 100644
--- a/sw/source/core/layout/paintfrm.cxx
+++ b/sw/source/core/layout/paintfrm.cxx
@@ -7749,12 +7749,11 @@ Graphic SwDrawFrameFormat::MakeGraphic( ImageMap* )
     if ( pMod )
     {
         SdrObject *pObj = FindSdrObject();
-        SdrView *pView = new SdrView( pMod );
+        std::unique_ptr<SdrView> pView( new SdrView( pMod ) );
         SdrPageView *pPgView = pView->ShowSdrPage(pView->GetModel()->GetPage(0));
         pView->MarkObj( pObj, pPgView );
         aRet = pView->GetMarkedObjBitmapEx();
         pView->HideSdrPage();
-        delete pView;
     }
     return aRet;
 }
diff --git a/sw/source/core/text/pormulti.cxx b/sw/source/core/text/pormulti.cxx
index 39bdf05..9927020 100644
--- a/sw/source/core/text/pormulti.cxx
+++ b/sw/source/core/text/pormulti.cxx
@@ -339,14 +339,13 @@ void SwDoubleLinePortion::PaintBracket( SwTextPaintInfo &rInf,
     aBlank.Width( nChWidth );
     aBlank.Height( pBracket->nHeight );
     {
-        SwFont* pTmpFnt = new SwFont( *rInf.GetFont() );
+        std::unique_ptr<SwFont> pTmpFnt( new SwFont( *rInf.GetFont() ) );
         SwFontScript nAct = bOpen ? pBracket->nPreScript : pBracket->nPostScript;
         if( SW_SCRIPTS > nAct )
             pTmpFnt->SetActual( nAct );
         pTmpFnt->SetProportion( 100 );
-        SwFontSave aSave( rInf, pTmpFnt );
+        SwFontSave aSave( rInf, pTmpFnt.get() );
         aBlank.Paint( rInf );
-        delete pTmpFnt;
     }
     if( bOpen )
         rInf.X( rInf.X() + PreWidth() );
diff --git a/sw/source/core/txtnode/fntcache.cxx b/sw/source/core/txtnode/fntcache.cxx
index 152e92c..b3dbcb6 100644
--- a/sw/source/core/txtnode/fntcache.cxx
+++ b/sw/source/core/txtnode/fntcache.cxx
@@ -1183,8 +1183,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
         // Simple kerning is handled by DrawStretchText
         if( rInf.GetSpace() || rInf.GetKanaComp() )
         {
-            long *pKernArray = new long[ rInf.GetLen() ];
-            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+            std::unique_ptr<long[]> pKernArray( new long[ rInf.GetLen() ] );
+            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
                                        rInf.GetIdx(), rInf.GetLen() );
 
             if( bStretch )
@@ -1230,7 +1230,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                      pSI && pSI->CountCompChg() &&
                      lcl_IsMonoSpaceFont( rInf.GetOut() ) )
                 {
-                    pSI->Compress( pKernArray, rInf.GetIdx(), rInf.GetLen(),
+                    pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
                                    rInf.GetKanaComp(),
                                    (sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
                     bSpecialJust = true;
@@ -1243,7 +1243,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
 
                     if (!MsLangId::isKorean(aLang))
                     {
-                        SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, nullptr,
+                        SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), nullptr,
                                 rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
 
                         bSpecialJust = true;
@@ -1257,7 +1257,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                     if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
                     {
                         if ( pSI && pSI->CountKashida() &&
-                            pSI->KashidaJustify( pKernArray, nullptr, rInf.GetIdx(),
+                            pSI->KashidaJustify( pKernArray.get(), nullptr, rInf.GetIdx(),
                                                  rInf.GetLen(), nSpaceAdd ) != -1 )
                         {
                             bSpecialJust = true;
@@ -1275,7 +1275,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                     {
                         // Use rInf.GetSpace() because it has more precision than
                         // nSpaceAdd:
-                        SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray, nullptr,
+                        SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(), nullptr,
                                                    rInf.GetIdx(), rInf.GetLen(),
                                                    rInf.GetNumberOfBlanks(),
                                                    rInf.GetSpace() );
@@ -1310,18 +1310,18 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                         pKernArray[0] = rInf.GetWidth() + nSpaceAdd;
 
                         rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
-                                                     pKernArray, rInf.GetIdx(), 1 );
+                                                     pKernArray.get(), rInf.GetIdx(), 1 );
                     }
                     else
                     {
                         pKernArray[ rInf.GetLen() - 2 ] += nSpaceAdd;
                         rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
-                            pKernArray, rInf.GetIdx(), rInf.GetLen() );
+                            pKernArray.get(), rInf.GetIdx(), rInf.GetLen() );
                     }
                 }
                 else
                     rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
-                                                 pKernArray, rInf.GetIdx(), rInf.GetLen() );
+                                                 pKernArray.get(), rInf.GetIdx(), rInf.GetLen() );
             }
             else
             {
@@ -1347,7 +1347,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                     rInf.GetOut().DrawText( aTmpPos, rInf.GetText(),
                                             rInf.GetIdx() + j, i - j );
             }
-            delete[] pKernArray;
         }
         else if( bStretch )
         {
@@ -1390,13 +1389,13 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
         bool bBullet = rInf.GetBullet();
         if( m_bSymbol )
             bBullet = false;
-        long* pKernArray = new long[ rInf.GetLen() ];
+        std::unique_ptr<long[]> pKernArray( new long[ rInf.GetLen() ] );
         CreateScrFont( *rInf.GetShell(), rInf.GetOut() );
         long nScrPos;
 
         // get screen array
-        long* pScrArray = new long[ rInf.GetLen() ];
-        rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray,
+        std::unique_ptr<long[]> pScrArray( new long[ rInf.GetLen() ] );
+        rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
                                     rInf.GetIdx(), rInf.GetLen() );
 
         // OLE: no printer available
@@ -1409,12 +1408,12 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 if( !m_pPrtFont->IsSameInstance( m_pPrinter->GetFont() ) )
                     m_pPrinter->SetFont( *m_pPrtFont );
             }
-            m_pPrinter->GetTextArray( rInf.GetText(), pKernArray, rInf.GetIdx(),
+            m_pPrinter->GetTextArray( rInf.GetText(), pKernArray.get(), rInf.GetIdx(),
                                     rInf.GetLen() );
         }
         else
         {
-            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
                                         rInf.GetIdx(), rInf.GetLen() );
         }
 
@@ -1434,10 +1433,10 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                  lcl_IsMonoSpaceFont( rInf.GetOut() ) )
             {
                 Point aTmpPos( aTextOriginPos );
-                pSI->Compress( pScrArray, rInf.GetIdx(), rInf.GetLen(),
+                pSI->Compress( pScrArray.get(), rInf.GetIdx(), rInf.GetLen(),
                                rInf.GetKanaComp(),
                                (sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTmpPos );
-                pSI->Compress( pKernArray, rInf.GetIdx(), rInf.GetLen(),
+                pSI->Compress( pKernArray.get(), rInf.GetIdx(), rInf.GetLen(),
                                rInf.GetKanaComp(),
                                (sal_uInt16)m_aFont.GetFontSize().Height(), lcl_IsFullstopCentered( rInf.GetOut() ), &aTextOriginPos );
             }
@@ -1449,7 +1448,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
 
                 if (!MsLangId::isKorean(aLang))
                 {
-                    SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray, pScrArray,
+                    SwScriptInfo::CJKJustify( rInf.GetText(), pKernArray.get(), pScrArray.get(),
                             rInf.GetIdx(), rInf.GetLen(), aLang, nSpaceAdd );
 
                     nSpaceAdd = 0;
@@ -1462,7 +1461,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 if ( SwScriptInfo::IsArabicText( rInf.GetText(), rInf.GetIdx(), rInf.GetLen() ) )
                 {
                     if ( pSI && pSI->CountKashida() &&
-                         pSI->KashidaJustify( pKernArray, pScrArray, rInf.GetIdx(),
+                         pSI->KashidaJustify( pKernArray.get(), pScrArray.get(), rInf.GetIdx(),
                                               rInf.GetLen(), nSpaceAdd ) != -1 )
                         nSpaceAdd = 0;
                     else
@@ -1477,8 +1476,8 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
 
                 if ( LANGUAGE_THAI == aLang )
                 {
-                    SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray,
-                                               pScrArray, rInf.GetIdx(),
+                    SwScriptInfo::ThaiJustify( rInf.GetText(), pKernArray.get(),
+                                               pScrArray.get(), rInf.GetIdx(),
                                                rInf.GetLen(),
                                                rInf.GetNumberOfBlanks(),
                                                rInf.GetSpace() );
@@ -1555,9 +1554,9 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 rInf.GetFrame()->SwitchHorizontalToVertical( aTextOriginPos );
 
             rInf.GetOut().DrawTextArray( aTextOriginPos, rInf.GetText(),
-                                         pKernArray, rInf.GetIdx(), 1 );
+                                         pKernArray.get(), rInf.GetIdx(), 1 );
             if( bBullet )
-                rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray,
+                rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get(),
                                              rInf.GetIdx() ? 1 : 0, 1 );
         }
         else
@@ -1712,7 +1711,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 {
                     CalcLinePosData aCalcLinePosData(rInf, GetFont(),
                             nCnt, bSwitchH2V, bSwitchL2R,
-                            nHalfSpace, pKernArray, bBidiPor);
+                            nHalfSpace, pKernArray.get(), bBidiPor);
 
                     SwForbidden aForbidden;
                     // draw line for smart tag data
@@ -1746,7 +1745,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 sal_Int32 nTmpIdx = bBullet ?
                                               ( rInf.GetIdx() ? 1 : 0 ) :
                                               rInf.GetIdx();
-                rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray + nOffs,
+                rInf.GetOut().DrawTextArray( aTextOriginPos, *pStr, pKernArray.get() + nOffs,
                                              nTmpIdx + nOffs , nLen - nOffs );
                 if (bBullet)
                 {
@@ -1784,7 +1783,7 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                                 pKernArray [ i - 1 ] -= nAdd;
                         }
                     }
-                    rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray + nOffs,
+                    rInf.GetOut().DrawTextArray( aTextOriginPos, aBulletOverlay, pKernArray.get() + nOffs,
                                                  nTmpIdx + nOffs , nLen - nOffs );
                     pTmpFont->SetColor( aPreviousColor );
 
@@ -1795,8 +1794,6 @@ void SwFntObj::DrawText( SwDrawTextInfo &rInf )
                 }
             }
         }
-        delete[] pScrArray;
-        delete[] pKernArray;
     }
 }
 
@@ -1920,8 +1917,8 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
             nScrPos = pKernArray[ nLn - 1 ];
         else
         {
-            long* pScrArray = new long[ rInf.GetLen() ];
-            rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray,
+            std::unique_ptr<long[]> pScrArray( new long[ rInf.GetLen() ] );
+            rInf.GetOut().GetTextArray( rInf.GetText(), pScrArray.get(),
                                         rInf.GetIdx(), rInf.GetLen() );
             nScrPos = pScrArray[ 0 ];
             sal_Int32 nCnt = rInf.GetText().getLength();
@@ -1958,7 +1955,6 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
                 nChPrev = nCh;
                 pKernArray[i-1] = nScrPos - nScr;
             }
-            delete[] pScrArray;
         }
 
         delete[] pKernArray;
@@ -1970,14 +1966,13 @@ Size SwFntObj::GetTextSize( SwDrawTextInfo& rInf )
             rInf.GetOut().SetFont( *m_pPrtFont );
         if( bCompress )
         {
-            long* pKernArray = new long[nLn];
-            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+            std::unique_ptr<long[]> pKernArray( new long[nLn] );
+            rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
                                         rInf.GetIdx(), nLn );
-            rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray,
+            rInf.SetKanaDiff( rInf.GetScriptInfo()->Compress( pKernArray.get(),
                 rInf.GetIdx(), nLn, rInf.GetKanaComp(),
                 (sal_uInt16) m_aFont.GetFontSize().Height() ,lcl_IsFullstopCentered( rInf.GetOut() ) ) );
             aTextSize.Width() = pKernArray[ nLn - 1 ];
-            delete[] pKernArray;
         }
         else
         {
@@ -2467,10 +2462,10 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth )
             nLn = 1;
         else if( nLn > 2 * nTextBreak2 )
             nLn = 2 * nTextBreak2;
-        long* pKernArray = new long[ nLn ];
-        rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray,
+        std::unique_ptr<long[]> pKernArray( new long[ nLn ] );
+        rInf.GetOut().GetTextArray( rInf.GetText(), pKernArray.get(),
                                     rInf.GetIdx(), nLn );
-        if( rInf.GetScriptInfo()->Compress( pKernArray, rInf.GetIdx(), nLn,
+        if( rInf.GetScriptInfo()->Compress( pKernArray.get(), rInf.GetIdx(), nLn,
                             rInf.GetKanaComp(), (sal_uInt16)GetHeight( m_nActual ),
                             lcl_IsFullstopCentered( rInf.GetOut() ) ) )
         {
@@ -2486,7 +2481,6 @@ sal_Int32 SwFont::GetTextBreak( SwDrawTextInfo& rInf, long nTextWidth )
             if( rInf.GetHyphPos() )
                 *rInf.GetHyphPos() += nTextBreak2 - nTmpBreak; // It's not perfect
         }
-        delete[] pKernArray;
     }
     nTextBreak2 = nTextBreak2 + rInf.GetIdx();
 
diff --git a/sw/source/core/unocore/unodraw.cxx b/sw/source/core/unocore/unodraw.cxx
index 35f794a..6681928 100644
--- a/sw/source/core/unocore/unodraw.cxx
+++ b/sw/source/core/unocore/unodraw.cxx
@@ -1124,8 +1124,8 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
                     }
                     else
                     {
-                        SwUnoInternalPaM* pInternalPam =
-                                        new SwUnoInternalPaM( *(pFormat->GetDoc()) );
+                        std::unique_ptr<SwUnoInternalPaM> pInternalPam(
+                                        new SwUnoInternalPaM( *(pFormat->GetDoc()) ));
                         uno::Reference< text::XTextRange > xRg;
                         aValue >>= xRg;
                         if (::sw::XTextRangeToSwPaM(*pInternalPam, xRg) )
@@ -1170,7 +1170,6 @@ void SwXShape::setPropertyValue(const OUString& rPropertyName, const uno::Any& a
                         {
                             throw uno::RuntimeException();
                         }
-                        delete pInternalPam;
                     }
                 }
                 else if (pEntry->nWID == FN_TEXT_BOX)
diff --git a/sw/source/filter/html/swhtml.cxx b/sw/source/filter/html/swhtml.cxx
index b990071..7ba89d0 100644
--- a/sw/source/filter/html/swhtml.cxx
+++ b/sw/source/filter/html/swhtml.cxx
@@ -2633,7 +2633,7 @@ SwViewShell *SwHTMLParser::CheckActionViewShell()
 void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
                              HTMLAttrs *pPostIts )
 {
-    SwPaM* pAttrPam = new SwPaM( *m_pPam->GetPoint() );
+    std::unique_ptr<SwPaM> pAttrPam( new SwPaM( *m_pPam->GetPoint() ) );
     const SwNodeIndex& rEndIdx = m_pPam->GetPoint()->nNode;
     const sal_Int32 nEndCnt = m_pPam->GetPoint()->nContent.GetIndex();
     HTMLAttr* pAttr;
@@ -2970,8 +2970,6 @@ void SwHTMLParser::SetAttr_( bool bChkEnd, bool bBeforeTable,
         aFields.pop_front();
         delete pAttr;
     }
-
-    delete pAttrPam;
 }
 
 void SwHTMLParser::NewAttr( HTMLAttr **ppAttr, const SfxPoolItem& rItem )
diff --git a/sw/source/filter/ww8/wrtw8esh.cxx b/sw/source/filter/ww8/wrtw8esh.cxx
index 9f50c20..2b8a8b2 100644
--- a/sw/source/filter/ww8/wrtw8esh.cxx
+++ b/sw/source/filter/ww8/wrtw8esh.cxx
@@ -275,10 +275,9 @@ void SwBasicEscherEx::WriteHyperlinkWithinFly( SvMemoryStream& rStrm, const SwFo
     sal_uInt32 const nLen = tmpStrm.remainingSize();
     if(nLen >0)
     {
-        sal_uInt8* pBuffer = new sal_uInt8[ nLen ];
-        tmpStrm.ReadBytes(pBuffer, nLen);
-        rStrm.WriteBytes(pBuffer, nLen);
-        delete[] pBuffer;
+        std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[ nLen ] );
+        tmpStrm.ReadBytes(pBuffer.get(), nLen);
+        rStrm.WriteBytes(pBuffer.get(), nLen);
     }
 }
 void SwBasicEscherEx::PreWriteHyperlinkWithinFly(const SwFrameFormat& rFormat,EscherPropertyContainer& rPropOpt)
diff --git a/sw/source/filter/ww8/wrtww8.cxx b/sw/source/filter/ww8/wrtww8.cxx
index 994a7b1..4710b54 100644
--- a/sw/source/filter/ww8/wrtww8.cxx
+++ b/sw/source/filter/ww8/wrtww8.cxx
@@ -3715,12 +3715,10 @@ void WW8Export::RestoreMacroCmds()
             pFib->m_lcbCmds = pStream->Tell();
             pStream->Seek(0);
 
-            sal_uInt8 *pBuffer = new sal_uInt8[pFib->m_lcbCmds];
-            bool bReadOk = checkRead(*pStream, pBuffer, pFib->m_lcbCmds);
+            std::unique_ptr<sal_uInt8[]> pBuffer( new sal_uInt8[pFib->m_lcbCmds] );
+            bool bReadOk = checkRead(*pStream, pBuffer.get(), pFib->m_lcbCmds);
             if (bReadOk)
-                pTableStrm->WriteBytes(pBuffer, pFib->m_lcbCmds);
-            delete[] pBuffer;
-
+                pTableStrm->WriteBytes(pBuffer.get(), pFib->m_lcbCmds);
         }
 
         delete pStream;
diff --git a/sw/source/filter/ww8/wrtww8gr.cxx b/sw/source/filter/ww8/wrtww8gr.cxx
index a19451e..959c9a2 100644
--- a/sw/source/filter/ww8/wrtww8gr.cxx
+++ b/sw/source/filter/ww8/wrtww8gr.cxx
@@ -335,7 +335,7 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
             xOleDst->Commit();
 
             // Ouput the cPicLocation attribute
-            ww::bytes* pBuf = new ww::bytes();
+            std::unique_ptr<ww::bytes> pBuf( new ww::bytes );
             SwWW8Writer::InsUInt16( *pBuf, NS_sprm::LN_CPicLocation );
             SwWW8Writer::InsUInt32( *pBuf, rOleId.copy( 1 ).toInt32() );
 
@@ -349,7 +349,6 @@ void WW8Export::OutputLinkedOLE( const OUString& rOleId )
             pBuf->push_back( 1 );
 
             m_pChpPlc->AppendFkpEntry( Strm().Tell(), pBuf->size(), pBuf->data() );
-            delete pBuf;
         }
     }
 }
diff --git a/sw/source/filter/ww8/ww8par2.cxx b/sw/source/filter/ww8/ww8par2.cxx
index 4d20e67..c1e1cb6 100644
--- a/sw/source/filter/ww8/ww8par2.cxx
+++ b/sw/source/filter/ww8/ww8par2.cxx
@@ -3614,10 +3614,9 @@ void WW8RStyle::ImportSprms(std::size_t nPosFc, short nLen, bool bPap)
 
     if (checkSeek(*pStStrm, nPosFc))
     {
-        sal_uInt8 *pSprms = new sal_uInt8[nLen];
-        nLen = pStStrm->ReadBytes(pSprms, nLen);
-        ImportSprms(pSprms, nLen, bPap);
-        delete[] pSprms;
+        std::unique_ptr<sal_uInt8[]> pSprms( new sal_uInt8[nLen] );
+        nLen = pStStrm->ReadBytes(pSprms.get(), nLen);
+        ImportSprms(pSprms.get(), nLen, bPap);
     }
 }
 
diff --git a/sw/source/filter/ww8/ww8scan.cxx b/sw/source/filter/ww8/ww8scan.cxx
index 3d221b2..0f98f30 100644
--- a/sw/source/filter/ww8/ww8scan.cxx
+++ b/sw/source/filter/ww8/ww8scan.cxx
@@ -5923,8 +5923,8 @@ void WW8Fib::WriteHeader(SvStream& rStrm)
     bool bVer8 = 8 == m_nVersion;
 
     size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
-    sal_uInt8 *pDataPtr = new sal_uInt8[ nUnencryptedHdr ];
-    sal_uInt8 *pData = pDataPtr;
+    std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ nUnencryptedHdr ] );
+    sal_uInt8 *pData = pDataPtr.get();
     memset( pData, 0, nUnencryptedHdr );
 
     const sal_uInt64 nPos = rStrm.Tell();
@@ -5999,8 +5999,7 @@ void WW8Fib::WriteHeader(SvStream& rStrm)
     // Marke: "rglw"  Beginning of the array of longs
     Set_UInt32( pData, m_cbMac );
 
-    rStrm.WriteBytes(pDataPtr, nUnencryptedHdr);
-    delete[] pDataPtr;
+    rStrm.WriteBytes(pDataPtr.get(), nUnencryptedHdr);
 }
 
 void WW8Fib::Write(SvStream& rStrm)
@@ -6011,8 +6010,8 @@ void WW8Fib::Write(SvStream& rStrm)
 
     size_t nUnencryptedHdr = bVer8 ? 0x44 : 0x24;
 
-    sal_uInt8 *pDataPtr = new sal_uInt8[ m_fcMin - nUnencryptedHdr ];
-    sal_uInt8 *pData = pDataPtr;
+    std::unique_ptr<sal_uInt8[]> pDataPtr( new sal_uInt8[ m_fcMin - nUnencryptedHdr ] );
+    sal_uInt8 *pData = pDataPtr.get();
     memset( pData, 0, m_fcMin - nUnencryptedHdr );
 
     const sal_uInt64 nPos = rStrm.Tell();
@@ -6243,8 +6242,7 @@ void WW8Fib::Write(SvStream& rStrm)
         Set_UInt32( pData, 0);
     }
 
-    rStrm.WriteBytes(pDataPtr, m_fcMin - nUnencryptedHdr);
-    delete[] pDataPtr;
+    rStrm.WriteBytes(pDataPtr.get(), m_fcMin - nUnencryptedHdr);
 }
 
 rtl_TextEncoding WW8Fib::GetFIBCharset(sal_uInt16 chs, sal_uInt16 nLidLocale)
@@ -6815,8 +6813,8 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
     sal_Int32 nFFn = rFib.m_lcbSttbfffn - 2;
 
     // allocate Font Array
-    sal_uInt8* pA = new sal_uInt8[nFFn];
-    memset(pA, 0, nFFn);
+    std::unique_ptr<sal_uInt8[]> pA( new sal_uInt8[nFFn] );
+    memset(pA.get(), 0, nFFn);
 
     ww::WordVersion eVersion = rFib.GetFIBVersion();
 
@@ -6832,9 +6830,9 @@ WW8Fonts::WW8Fonts( SvStream& rSt, WW8Fib& rFib )
     rSt.SeekRel( 2 );
 
     // read all font information
-    nFFn = rSt.ReadBytes(pA, nFFn);
-    sal_uInt8 * const pEnd = pA + nFFn;
-    const sal_uInt16 nCalcMax = calcMaxFonts(pA, nFFn);
+    nFFn = rSt.ReadBytes(pA.get(), nFFn);
+    sal_uInt8 * const pEnd = pA.get() + nFFn;

... etc. - the rest is truncated


More information about the Libreoffice-commits mailing list