summaryrefslogtreecommitdiff
path: root/lotuswordpro/source/filter/lwpobjstrm.cxx
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-03-14 12:03:59 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-03-14 12:09:54 +0000
commitd18421575c7f1eb97d08cde6184c082e5ab828c3 (patch)
tree498c7ea8282321a604c569552cfff6dc6a459a05 /lotuswordpro/source/filter/lwpobjstrm.cxx
parentbde834ee6b0cb43cebece47cac55cc9b80aadc24 (diff)
ofz: use std::vector for long buffers
and set size of buffer to successfully read data for short reads Change-Id: I8d132446682104f2a4b8c476b7f2bda188bb3cdf
Diffstat (limited to 'lotuswordpro/source/filter/lwpobjstrm.cxx')
-rw-r--r--lotuswordpro/source/filter/lwpobjstrm.cxx39
1 files changed, 10 insertions, 29 deletions
diff --git a/lotuswordpro/source/filter/lwpobjstrm.cxx b/lotuswordpro/source/filter/lwpobjstrm.cxx
index bc968a550f43..398a45dce2a5 100644
--- a/lotuswordpro/source/filter/lwpobjstrm.cxx
+++ b/lotuswordpro/source/filter/lwpobjstrm.cxx
@@ -71,24 +71,16 @@ LwpObjectStream::LwpObjectStream(LwpSvStream *pStrm, bool isCompressed, sal_uInt
if (size >= IO_BUFFERSIZE)
throw std::range_error("bad Object size");
// read object data from stream
- if(m_nBufSize == 0)
- {
- m_pContentBuf = nullptr;
- }
- else
- {
+ if (m_nBufSize > 0)
Read2Buffer();
- }
}
+
/**
* @descr read object data from stream to buffer
*/
void LwpObjectStream::Read2Buffer()
{
- if( m_pContentBuf )
- {
- ReleaseBuffer();
- }
+ ReleaseBuffer();
m_nReadPos = 0;
@@ -98,7 +90,7 @@ void LwpObjectStream::Read2Buffer()
sal_uInt8* pCompressBuffer = xCompressBuf.get();
memset(pCompressBuffer, 0, m_nBufSize);
- m_pStrm->Read(pCompressBuffer, m_nBufSize);
+ m_nBufSize = m_pStrm->Read(pCompressBuffer, m_nBufSize);
sal_uInt8 pTempDst[IO_BUFFERSIZE];
m_nBufSize = DecompressBuffer(pTempDst, pCompressBuffer, m_nBufSize);
@@ -106,13 +98,11 @@ void LwpObjectStream::Read2Buffer()
m_pContentBuf = AllocBuffer(m_nBufSize);
memcpy(m_pContentBuf, pTempDst, m_nBufSize);
- //delete [] pTempDst;
-
}
else
{
m_pContentBuf = AllocBuffer(m_nBufSize);
- m_pStrm->Read(m_pContentBuf, m_nBufSize);
+ m_nBufSize = m_pStrm->Read(m_pContentBuf, m_nBufSize);
}
}
/**
@@ -120,14 +110,12 @@ void LwpObjectStream::Read2Buffer()
*/
sal_uInt8* LwpObjectStream::AllocBuffer(sal_uInt16 size)
{
- if(size<=100)
+ if (size<=100)
{
return m_SmallBuffer;
}
- else
- {
- return new sal_uInt8[size];
- }
+ m_BigBuffer.resize(size);
+ return m_BigBuffer.data();
}
/**
* @descr signal complete to release object buffer
@@ -146,15 +134,8 @@ LwpObjectStream::~LwpObjectStream()
*/
void LwpObjectStream::ReleaseBuffer()
{
-
- if(m_nBufSize>100)
- {
- if(m_pContentBuf)
- {
- delete [] m_pContentBuf;
- m_pContentBuf = nullptr;
- }
- }
+ m_BigBuffer.clear();
+ m_pContentBuf = nullptr;
}
sal_uInt16 LwpObjectStream::remainingSize() const