summaryrefslogtreecommitdiff
path: root/lotuswordpro
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2018-10-18 14:57:08 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2018-10-19 07:58:31 +0200
commit8b1a6e68536daee46c8a39ef855e6638df0f07b0 (patch)
tree086e6f2d4a1da7d2b7b34f932245b57b96b04427 /lotuswordpro
parente61e4e56994c22221dcc0e9f4c2cb62fd63ac823 (diff)
use unique_ptr in LwpGraphicObject::GetGrafData
Change-Id: I19ba8eb5251af3b0c381275a0a18cf8c50944372 Reviewed-on: https://gerrit.libreoffice.org/61941 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'lotuswordpro')
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.cxx12
-rw-r--r--lotuswordpro/source/filter/lwpgrfobj.hxx2
2 files changed, 5 insertions, 9 deletions
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<sal_uInt8> 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<sal_uInt8[]>& 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<sal_uInt8[]> 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<sal_uInt8> GetRawGrafData();
- sal_uInt32 GetGrafData(sal_uInt8*& pGrafData);
+ sal_uInt32 GetGrafData(std::unique_ptr<sal_uInt8[]>& pGrafData);
void GetGrafOrgSize(long& rWidth, long& rHeight) { rWidth = m_Cache.Width; rHeight = m_Cache.Height; }
void GetGrafOrgSize(double& rWidth, double& rHeight) override;