Kaydet (Commit) 8f855953 authored tarafından Caolán McNamara's avatar Caolán McNamara

coverity#1343637 Double free

and

coverity#1343638 Double free
coverity#13436397 Double free
coverity#1343640 Double free
coverity#1343641 Double free

Change-Id: I8ce42f03d40fe514f73b3a7eabdb4f323b2239e6
üst 7b6ffbcc
...@@ -28,6 +28,7 @@ ...@@ -28,6 +28,7 @@
#include <tools/ref.hxx> #include <tools/ref.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <cppuhelper/implbase1.hxx> #include <cppuhelper/implbase1.hxx>
#include <xmloff/nmspmap.hxx>
class SvXMLNamespaceMap; class SvXMLNamespaceMap;
class SvXMLImport; class SvXMLImport;
...@@ -42,11 +43,10 @@ class XMLOFF_DLLPUBLIC SvXMLImportContext : public SvRefBase, ...@@ -42,11 +43,10 @@ class XMLOFF_DLLPUBLIC SvXMLImportContext : public SvRefBase,
sal_uInt16 mnPrefix; sal_uInt16 mnPrefix;
OUString maLocalName; OUString maLocalName;
SvXMLNamespaceMap *mpRewindMap; std::unique_ptr<SvXMLNamespaceMap> mxRewindMap;
SAL_DLLPRIVATE SvXMLNamespaceMap *TakeRewindMap() SAL_DLLPRIVATE SvXMLNamespaceMap *TakeRewindMap() { return mxRewindMap.release(); }
{ auto p = mpRewindMap; mpRewindMap = nullptr; return p; } SAL_DLLPRIVATE void PutRewindMap( SvXMLNamespaceMap *p ) { mxRewindMap.reset(p); }
SAL_DLLPRIVATE void PutRewindMap( SvXMLNamespaceMap *p ) { mpRewindMap = p; }
protected: protected:
......
...@@ -23,31 +23,27 @@ ...@@ -23,31 +23,27 @@
#include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <com/sun/star/xml/sax/XLocator.hpp> #include <com/sun/star/xml/sax/XLocator.hpp>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmlimp.hxx> #include <xmloff/xmlimp.hxx>
#include <xmloff/xmlictxt.hxx> #include <xmloff/xmlictxt.hxx>
using namespace ::com::sun::star; using namespace ::com::sun::star;
SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx, SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp, sal_uInt16 nPrfx,
const OUString& rLName ) : const OUString& rLName )
mrImport( rImp ), : mrImport(rImp)
mnPrefix( nPrfx ), , mnPrefix(nPrfx)
maLocalName( rLName ), , maLocalName(rLName)
mpRewindMap( nullptr )
{ {
} }
SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp ) : SvXMLImportContext::SvXMLImportContext( SvXMLImport& rImp )
mrImport( rImp ), : mrImport(rImp)
mnPrefix ( 0 ), , mnPrefix(0)
mpRewindMap( nullptr )
{ {
} }
SvXMLImportContext::~SvXMLImportContext() SvXMLImportContext::~SvXMLImportContext()
{ {
delete mpRewindMap;
} }
SvXMLImportContext *SvXMLImportContext::CreateChildContext( sal_uInt16 nPrefix, SvXMLImportContext *SvXMLImportContext::CreateChildContext( sal_uInt16 nPrefix,
......
...@@ -22,7 +22,6 @@ ...@@ -22,7 +22,6 @@
#include <com/sun/star/xml/sax/XDocumentHandler.hpp> #include <com/sun/star/xml/sax/XDocumentHandler.hpp>
#include <com/sun/star/xml/sax/XAttributeList.hpp> #include <com/sun/star/xml/sax/XAttributeList.hpp>
#include <osl/diagnose.h> #include <osl/diagnose.h>
#include <xmloff/nmspmap.hxx>
#include "TransformerBase.hxx" #include "TransformerBase.hxx"
...@@ -47,16 +46,14 @@ bool XMLTransformerContext::HasNamespace( sal_uInt16 nPrefix ) const ...@@ -47,16 +46,14 @@ bool XMLTransformerContext::HasNamespace( sal_uInt16 nPrefix ) const
} }
XMLTransformerContext::XMLTransformerContext( XMLTransformerBase& rImp, XMLTransformerContext::XMLTransformerContext( XMLTransformerBase& rImp,
const OUString& rQName ) : const OUString& rQName )
m_rTransformer( rImp ), : m_rTransformer(rImp)
m_aQName( rQName ), , m_aQName(rQName)
m_pRewindMap( nullptr )
{ {
} }
XMLTransformerContext::~XMLTransformerContext() XMLTransformerContext::~XMLTransformerContext()
{ {
delete m_pRewindMap;
} }
rtl::Reference<XMLTransformerContext> XMLTransformerContext::CreateChildContext( sal_uInt16 nPrefix, rtl::Reference<XMLTransformerContext> XMLTransformerContext::CreateChildContext( sal_uInt16 nPrefix,
......
...@@ -24,6 +24,7 @@ ...@@ -24,6 +24,7 @@
#include <salhelper/simplereferenceobject.hxx> #include <salhelper/simplereferenceobject.hxx>
#include <rtl/ref.hxx> #include <rtl/ref.hxx>
#include <rtl/ustring.hxx> #include <rtl/ustring.hxx>
#include <xmloff/nmspmap.hxx>
#include <xmloff/xmltoken.hxx> #include <xmloff/xmltoken.hxx>
class SvXMLNamespaceMap; class SvXMLNamespaceMap;
...@@ -37,11 +38,10 @@ class XMLTransformerContext : public ::salhelper::SimpleReferenceObject ...@@ -37,11 +38,10 @@ class XMLTransformerContext : public ::salhelper::SimpleReferenceObject
OUString m_aQName; OUString m_aQName;
SvXMLNamespaceMap *m_pRewindMap; std::unique_ptr<SvXMLNamespaceMap> m_xRewindMap;
SvXMLNamespaceMap *TakeRewindMap() SvXMLNamespaceMap *TakeRewindMap() { return m_xRewindMap.release(); }
{ auto p = m_pRewindMap; m_pRewindMap = nullptr; return p; } void PutRewindMap( SvXMLNamespaceMap *p ) { m_xRewindMap.reset(p); }
void PutRewindMap( SvXMLNamespaceMap *p ) { m_pRewindMap = p; }
protected: protected:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment