[Libreoffice-commits] core.git: basic/source
Mike Kaganski (via logerrit)
logerrit at kemper.freedesktop.org
Mon Nov 23 14:11:59 UTC 2020
basic/source/comp/buffer.cxx | 22 ++++++----------------
1 file changed, 6 insertions(+), 16 deletions(-)
New commits:
commit 9f791ae23a19aa2e37b417c1696e216455b2c909
Author: Mike Kaganski <mike.kaganski at collabora.com>
AuthorDate: Mon Nov 23 12:29:25 2020 +0300
Commit: Mike Kaganski <mike.kaganski at collabora.com>
CommitDate: Mon Nov 23 15:11:12 2020 +0100
Simplify SbiBuffer::Check
Change-Id: Ic90d8ee858d25bed36c89f95d5de94440cb48f1f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106399
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski at collabora.com>
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;
}
More information about the Libreoffice-commits
mailing list