diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2020-11-23 12:29:25 +0300 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2020-11-23 15:11:12 +0100 |
commit | 9f791ae23a19aa2e37b417c1696e216455b2c909 (patch) | |
tree | bf2f3b1b8876d8dfa89d659e5ff5c35562109266 /basic | |
parent | 1ab938155c875e65470b9f6b3b3ef65885462f7a (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.cxx | 22 |
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; } |