summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-11-23 12:29:25 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-11-23 15:11:12 +0100
commit9f791ae23a19aa2e37b417c1696e216455b2c909 (patch)
treebf2f3b1b8876d8dfa89d659e5ff5c35562109266 /basic
parent1ab938155c875e65470b9f6b3b3ef65885462f7a (diff)
Simplify SbiBuffer::Check
Change-Id: Ic90d8ee858d25bed36c89f95d5de94440cb48f1f Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106399 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/comp/buffer.cxx22
1 files changed, 6 insertions, 16 deletions
diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx
index bb7bc596ff67..b0d87bdaef4d 100644
--- a/basic/source/comp/buffer.cxx
+++ b/basic/source/comp/buffer.cxx
@@ -74,29 +74,19 @@ bool SbiBuffer::Check( sal_Int32 n )
{
nn = nn + nInc;
}
- char* p;
if( ( nSize + nn ) > UP_LIMIT )
{
- p = nullptr;
- }
- else
- {
- p = new char [nSize + nn];
- }
- if( !p )
- {
pParser->Error( ERRCODE_BASIC_PROG_TOO_LARGE );
nInc = 0;
pBuf.reset();
return false;
}
- else
- {
- if( nSize ) memcpy( p, pBuf.get(), nSize );
- pBuf.reset(p);
- pCur = pBuf.get() + nOff;
- nSize = nSize + nn;
- }
+ auto p(std::make_unique<char[]>(nSize + nn));
+ if (nSize)
+ memcpy(p.get(), pBuf.get(), nSize);
+ pBuf = std::move(p);
+ pCur = pBuf.get() + nOff;
+ nSize += nn;
}
return true;
}