diff --git a/lotuswordpro/source/filter/lwpgrfobj.cxx b/lotuswordpro/source/filter/lwpgrfobj.cxx index 61f35d0879e4..6e0069bf98a8 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.cxx +++ b/lotuswordpro/source/filter/lwpgrfobj.cxx @@ -355,7 +355,7 @@ std::vector LwpGraphicObject::GetRawGrafData() * @param pGrafData the array to store the image data. the pointer need to be deleted outside. * @return the length of the image data. */ -sal_uInt32 LwpGraphicObject::GetGrafData(sal_uInt8*& pGrafData) +sal_uInt32 LwpGraphicObject::GetGrafData(std::unique_ptr& pGrafData) { // create graphic object // if small file, use the compressed stream for BENTO @@ -386,8 +386,8 @@ sal_uInt32 LwpGraphicObject::GetGrafData(sal_uInt8*& pGrafData) // read image data sal_uInt32 nDataLen = pGrafStream->TellEnd(); - pGrafData = new sal_uInt8 [nDataLen]; - pMemGrafStream->ReadBytes(pGrafData, nDataLen); + pGrafData.reset(new sal_uInt8 [nDataLen]); + pMemGrafStream->ReadBytes(pGrafData.get(), nDataLen); delete pMemGrafStream; pMemGrafStream = nullptr; @@ -643,7 +643,7 @@ void LwpGraphicObject::CreateGrafObject() */ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont) { - sal_uInt8* pGrafData = nullptr; + std::unique_ptr pGrafData; sal_uInt32 nDataLen = GetGrafData(pGrafData); if(pGrafData) { @@ -687,11 +687,7 @@ void LwpGraphicObject::XFConvertEquation(XFContentContainer * pCont) pXFPara->Add(pXFNote); pCont->Add(pXFPara); - - delete [] pGrafData; - pGrafData = nullptr; } - } void LwpGraphicObject::GetGrafOrgSize(double & rWidth, double & rHeight) diff --git a/lotuswordpro/source/filter/lwpgrfobj.hxx b/lotuswordpro/source/filter/lwpgrfobj.hxx index 726d8ec049cc..969e0c0f05d3 100644 --- a/lotuswordpro/source/filter/lwpgrfobj.hxx +++ b/lotuswordpro/source/filter/lwpgrfobj.hxx @@ -119,7 +119,7 @@ public: void CreateGrafObject(); static void GetBentoNamebyID(LwpObjectID const & rMyID, std::string& rName); std::vector GetRawGrafData(); - sal_uInt32 GetGrafData(sal_uInt8*& pGrafData); + sal_uInt32 GetGrafData(std::unique_ptr& pGrafData); void GetGrafOrgSize(long& rWidth, long& rHeight) { rWidth = m_Cache.Width; rHeight = m_Cache.Height; } void GetGrafOrgSize(double& rWidth, double& rHeight) override;