summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorMike Kaganski <mike.kaganski@collabora.com>2020-11-23 22:43:31 +0300
committerMike Kaganski <mike.kaganski@collabora.com>2020-11-24 17:11:53 +0100
commitd84deb9536373ddc9efcf513e9d88035215bd735 (patch)
tree7524ed284ea3deb2b2712c46eaa24268541cf970 /basic
parentd4ca173f2babde53c1d20f10e335244b092c5c97 (diff)
Use std::vector in SbiBuffer
This removes memory management from the class; unifies the types used throughout the code using it; and simplifies it all greatly. Also this changes errors handling. Prevoiusly setting errors to parser didn't handle case when no parser was passed to SbiBuffer ctor, as BufferTransformer did, and could dereference nullptr. Change-Id: I068eb1b3e9a616a5744fc8233781c4dd4403c84d Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106452 Tested-by: Jenkins Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic')
-rw-r--r--basic/source/classes/image.cxx47
-rw-r--r--basic/source/comp/buffer.cxx197
-rw-r--r--basic/source/comp/codegen.cxx15
-rw-r--r--basic/source/comp/parser.cxx2
-rw-r--r--basic/source/inc/buffer.hxx34
-rw-r--r--basic/source/inc/codegen.hxx19
-rw-r--r--basic/source/inc/image.hxx13
-rw-r--r--basic/source/runtime/runtime.cxx8
8 files changed, 108 insertions, 227 deletions
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index e17b391f3d55..0fd760a1c21b 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -33,8 +33,6 @@ SbiImage::SbiImage()
: bError(false)
, nFlags(SbiImageFlags::NONE)
, nStringSize(0)
- , nCodeSize(0)
- , nLegacyCodeSize(0)
, nDimBase(0)
, eCharSet(osl_getThreadTextEncoding())
, nStringIdx(0)
@@ -52,12 +50,10 @@ void SbiImage::Clear()
{
mvStringOffsets.clear();
pStrings.reset();
- pCode.reset();
- pLegacyPCode.reset();
+ aCode.clear();
+ aLegacyPCode.clear();
nFlags = SbiImageFlags::NONE;
nStringSize= 0;
- nLegacyCodeSize = 0;
- nCodeSize = 0;
eCharSet = osl_getThreadTextEncoding();
nDimBase = 0;
bError = false;
@@ -177,18 +173,16 @@ bool SbiImage::Load( SvStream& r, sal_uInt32& nVersion )
}
case FileOffset::PCode:
if( bBadVer ) break;
- pCode.reset(new char[ nLen ]);
- nCodeSize = nLen;
- r.ReadBytes(pCode.get(), nCodeSize);
+ aCode.resize(nLen);
+ r.ReadBytes(aCode.data(), aCode.size());
if ( bLegacy )
{
- nLegacyCodeSize = static_cast<sal_uInt16>(nCodeSize);
- pLegacyPCode = std::move(pCode);
+ aLegacyPCode = std::move(aCode);
- PCodeBuffConvertor< sal_uInt16, sal_uInt32 > aLegacyToNew( reinterpret_cast<sal_uInt8*>(pLegacyPCode.get()), nLegacyCodeSize );
+ PCodeBuffConvertor<sal_uInt16, sal_uInt32> aLegacyToNew(aLegacyPCode.data(),
+ aLegacyPCode.size());
aLegacyToNew.convert();
- pCode.reset(reinterpret_cast<char*>(aLegacyToNew.GetBuffer()));
- nCodeSize = aLegacyToNew.GetSize();
+ aCode = aLegacyToNew.GetBuffer();
// we don't release the legacy buffer
// right now, that's because the module
// needs it to fix up the method
@@ -434,20 +428,19 @@ bool SbiImage::Save( SvStream& r, sal_uInt32 nVer )
SbiCloseRecord( r, nPos );
}
// Binary data?
- if( pCode && SbiGood( r ) )
+ if (aCode.size() && SbiGood(r))
{
nPos = SbiOpenRecord( r, FileOffset::PCode, 1 );
if ( bLegacy )
{
- PCodeBuffConvertor< sal_uInt32, sal_uInt16 > aNewToLegacy( reinterpret_cast<sal_uInt8*>(pCode.get()), nCodeSize );
+ PCodeBuffConvertor<sal_uInt32, sal_uInt16> aNewToLegacy(aCode.data(), aCode.size());
aNewToLegacy.convert();
- pLegacyPCode.reset(reinterpret_cast<char*>(aNewToLegacy.GetBuffer()));
- nLegacyCodeSize = aNewToLegacy.GetSize();
- r.WriteBytes(pLegacyPCode.get(), nLegacyCodeSize);
+ aLegacyPCode = aNewToLegacy.GetBuffer();
+ r.WriteBytes(aLegacyPCode.data(), aLegacyPCode.size());
}
else
{
- r.WriteBytes(pCode.get(), nCodeSize);
+ r.WriteBytes(aCode.data(), aCode.size());
}
SbiCloseRecord( r, nPos );
}
@@ -626,10 +619,9 @@ void SbiImage::AddString( const OUString& r )
// The block was fetched by the compiler from class SbBuffer and
// is already created with new. Additionally it contains all Integers
// in Big Endian format, so can be directly read/written.
-void SbiImage::AddCode( std::unique_ptr<char[]> p, sal_uInt32 s )
+void SbiImage::AddCode(std::vector<sal_uInt8>&& v)
{
- pCode = std::move(p);
- nCodeSize = s;
+ aCode = std::move(v);
}
// Add user type
@@ -685,23 +677,22 @@ const SbxObject* SbiImage::FindType (const OUString& aTypeName) const
sal_uInt16 SbiImage::CalcLegacyOffset( sal_Int32 nOffset )
{
- return SbiCodeGen::calcLegacyOffSet( reinterpret_cast<sal_uInt8*>(pCode.get()), nOffset ) ;
+ return SbiCodeGen::calcLegacyOffSet(aCode.data(), nOffset);
}
sal_uInt32 SbiImage::CalcNewOffset( sal_Int16 nOffset )
{
- return SbiCodeGen::calcNewOffSet( reinterpret_cast<sal_uInt8*>(pLegacyPCode.get()), nOffset ) ;
+ return SbiCodeGen::calcNewOffSet(aLegacyPCode.data(), nOffset);
}
void SbiImage::ReleaseLegacyBuffer()
{
- pLegacyPCode.reset();
- nLegacyCodeSize = 0;
+ aLegacyPCode.clear();
}
bool SbiImage::ExceedsLegacyLimits()
{
- return ( nStringSize > 0xFF00 ) || ( CalcLegacyOffset( nCodeSize ) > 0xFF00 );
+ return (nStringSize > 0xFF00) || (CalcLegacyOffset(aCode.size()) > 0xFF00);
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/comp/buffer.cxx b/basic/source/comp/buffer.cxx
index b0d87bdaef4d..3d0880f7c678 100644
--- a/basic/source/comp/buffer.cxx
+++ b/basic/source/comp/buffer.cxx
@@ -18,93 +18,54 @@
*/
#include <buffer.hxx>
-#include <parser.hxx>
-#include <basic/sberrors.hxx>
-
-const sal_uInt32 UP_LIMIT=0xFFFFFF00;
-
-// The SbiBuffer will be expanded in increments of at least 16 Bytes.
-// This is necessary, because many classes emanate from a buffer length
-// of x*16 Bytes.
-
-SbiBuffer::SbiBuffer( SbiParser* p, short n )
- : pParser(p)
- , pCur(nullptr)
- , nOff(0)
- , nSize(0)
+namespace
{
- n = ( (n + 15 ) / 16 ) * 16;
- if( !n ) n = 16;
- nInc = n;
-}
+const sal_uInt32 UP_LIMIT=0xFFFFFF00;
-SbiBuffer::~SbiBuffer()
+template <class I, typename T> void write(I it, T n)
{
+ *it = static_cast<sal_uInt8>(n & 0xFF);
+ if constexpr (sizeof(n) > 1)
+ {
+ for (std::size_t i = 1; i < sizeof(n); ++i)
+ {
+ n >>= 8;
+ *++it = static_cast<sal_uInt8>(n & 0xFF);
+ }
+ }
}
-
-// Reach out the buffer
-// This lead to the deletion of the buffer!
-
-char* SbiBuffer::GetBuffer()
-{
- char* p = pBuf.release();
- pCur = nullptr;
- return p;
}
-// Test, if the buffer can contain n Bytes.
-// In case of doubt it will be enlarged
-
-bool SbiBuffer::Check( sal_Int32 n )
+template <typename T> void SbiBuffer::append(T n)
{
- if( !n )
- {
- return true;
- }
- if( nOff + n > nSize )
+ if (m_aErrCode)
+ return;
+ if ((m_aBuf.size() + sizeof(n)) > UP_LIMIT)
{
- if( nInc == 0 )
- {
- return false;
- }
-
- sal_Int32 nn = 0;
- while( nn < n )
- {
- nn = nn + nInc;
- }
- if( ( nSize + nn ) > UP_LIMIT )
- {
- pParser->Error( ERRCODE_BASIC_PROG_TOO_LARGE );
- nInc = 0;
- pBuf.reset();
- return false;
- }
- 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;
+ m_aErrCode = ERRCODE_BASIC_PROG_TOO_LARGE;
+ m_aBuf.clear();
+ return;
}
- return true;
+ m_aBuf.reserve(m_aBuf.size() + sizeof(n));
+ write(std::back_inserter(m_aBuf), n);
}
+void SbiBuffer::operator+=(sal_Int8 n) { append(n); }
+void SbiBuffer::operator+=(sal_Int16 n) { append(n); }
+void SbiBuffer::operator+=(sal_uInt8 n) { append(n); }
+void SbiBuffer::operator+=(sal_uInt16 n) { append(n); }
+void SbiBuffer::operator+=(sal_uInt32 n) { append(n); }
+void SbiBuffer::operator+=(sal_Int32 n) { append(n); }
+
// Patch of a Location
void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val )
{
- if( ( off + sizeof( sal_uInt32 ) ) < nOff )
- {
- sal_uInt16 val1 = static_cast<sal_uInt16>( val & 0xFFFF );
- sal_uInt16 val2 = static_cast<sal_uInt16>( val >> 16 );
- sal_uInt8* p = reinterpret_cast<sal_uInt8*>(pBuf.get()) + off;
- *p++ = static_cast<char>( val1 & 0xFF );
- *p++ = static_cast<char>( val1 >> 8 );
- *p++ = static_cast<char>( val2 & 0xFF );
- *p = static_cast<char>( val2 >> 8 );
- }
+ if (m_aErrCode)
+ return;
+ if ((off + sizeof(sal_uInt32)) <= GetSize())
+ write(m_aBuf.begin() + off, val);
}
// Forward References upon label and procedures
@@ -113,98 +74,20 @@ void SbiBuffer::Patch( sal_uInt32 off, sal_uInt32 val )
void SbiBuffer::Chain( sal_uInt32 off )
{
- if( !(off && pBuf) )
+ if (m_aErrCode)
return;
-
- sal_uInt8 *ip;
- sal_uInt32 i = off;
- sal_uInt32 val1 = (nOff & 0xFFFF);
- sal_uInt32 val2 = (nOff >> 16);
- do
+ for (sal_uInt32 i = off; i;)
{
- ip = reinterpret_cast<sal_uInt8*>(pBuf.get()) + i;
- sal_uInt8* pTmp = ip;
- i = *pTmp++; i |= *pTmp++ << 8; i |= *pTmp++ << 16; i |= *pTmp++ << 24;
-
- if( i >= nOff )
+ if ((i + sizeof(sal_uInt32)) > GetSize())
{
- pParser->Error( ERRCODE_BASIC_INTERNAL_ERROR, "BACKCHAIN" );
+ m_aErrCode = ERRCODE_BASIC_INTERNAL_ERROR;
+ m_sErrMsg = OUStringLiteral(u"BACKCHAIN");
break;
}
- *ip++ = static_cast<char>( val1 & 0xFF );
- *ip++ = static_cast<char>( val1 >> 8 );
- *ip++ = static_cast<char>( val2 & 0xFF );
- *ip = static_cast<char>( val2 >> 8 );
- } while( i );
-}
-
-void SbiBuffer::operator +=( sal_Int8 n )
-{
- if( Check( 1 ) )
- {
- *pCur++ = static_cast<char>(n);
- nOff += 1;
- }
-}
-
-bool SbiBuffer::operator +=( sal_uInt8 n )
-{
- if( Check( 1 ) )
- {
- *pCur++ = static_cast<char>(n);
- nOff += 1;
- return true;
- }
- else
- {
- return false;
- }
-}
-
-void SbiBuffer::operator +=( sal_Int16 n )
-{
- if( Check( 2 ) )
- {
- *pCur++ = static_cast<char>( n & 0xFF );
- *pCur++ = static_cast<char>( n >> 8 );
- nOff += 2;
- }
-}
-
-bool SbiBuffer::operator +=( sal_uInt16 n )
-{
- if( Check( 2 ) )
- {
- *pCur++ = static_cast<char>( n & 0xFF );
- *pCur++ = static_cast<char>( n >> 8 );
- nOff += 2;
- return true;
- }
- else
- {
- return false;
- }
-}
-
-bool SbiBuffer::operator +=( sal_uInt32 n )
-{
- if( Check( 4 ) )
- {
- sal_uInt16 n1 = static_cast<sal_uInt16>( n & 0xFFFF );
- sal_uInt16 n2 = static_cast<sal_uInt16>( n >> 16 );
- operator +=(n1) && operator +=(n2);
- return true;
- }
- else
- {
- return false;
+ auto ip = m_aBuf.begin() + i;
+ i = ip[0] | (ip[1] << 8) | (ip[2] << 16) | (ip[3] << 24);
+ write(ip, GetSize());
}
}
-void SbiBuffer::operator +=( sal_Int32 n )
-{
- operator +=( static_cast<sal_uInt32>(n) );
-}
-
-
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/comp/codegen.cxx b/basic/source/comp/codegen.cxx
index b20d22c72078..87daa849f74f 100644
--- a/basic/source/comp/codegen.cxx
+++ b/basic/source/comp/codegen.cxx
@@ -36,10 +36,9 @@
// nInc is the increment size of the buffers
-SbiCodeGen::SbiCodeGen( SbModule& r, SbiParser* p, short nInc )
+SbiCodeGen::SbiCodeGen(SbModule& r, SbiParser* p)
: pParser(p)
, rMod(r)
- , aCode(p, nInc)
, nLine(0)
, nCol(0)
, nForLevel(0)
@@ -356,8 +355,12 @@ void SbiCodeGen::Save()
} // for( iPass...
}
}
+ if (aCode.GetErrCode())
+ {
+ pParser->Error(aCode.GetErrCode(), aCode.GetErrMessage());
+ }
// The code
- p->AddCode( std::unique_ptr<char[]>(aCode.GetBuffer()), aCode.GetSize() );
+ p->AddCode(aCode.GetBuffer());
// The global StringPool. 0 is not occupied.
SbiStringPool* pPool = &pParser->aGblStrings;
@@ -498,7 +501,7 @@ class BufferTransformer : public PCodeVisitor< T >
const sal_uInt8* m_pStart;
SbiBuffer m_ConvertedBuf;
public:
- BufferTransformer():m_pStart(nullptr), m_ConvertedBuf( nullptr, 1024 ) {}
+ BufferTransformer():m_pStart(nullptr) {}
virtual void start( const sal_uInt8* pStart ) override { m_pStart = pStart; }
virtual void processOpCode0( SbiOpcode eOp ) override
{
@@ -576,8 +579,8 @@ PCodeBuffConvertor<T,S>::convert()
PCodeBufferWalker< T > aBuf( m_pStart, m_nSize );
BufferTransformer< T, S > aTrnsfrmer;
aBuf.visitBuffer( aTrnsfrmer );
- m_pCnvtdBuf = reinterpret_cast<sal_uInt8*>(aTrnsfrmer.buffer().GetBuffer());
- m_nCnvtdSize = static_cast<S>( aTrnsfrmer.buffer().GetSize() );
+ // TODO: handle buffer errors
+ m_aCnvtdBuf = aTrnsfrmer.buffer().GetBuffer();
}
template class PCodeBuffConvertor< sal_uInt16, sal_uInt32 >;
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 9d53c8269113..6ebc2208ae42 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -121,7 +121,7 @@ SbiParser::SbiParser( StarBASIC* pb, SbModule* pm )
aGlobals( aGblStrings, SbGLOBAL, this ),
aPublics( aGblStrings, SbPUBLIC, this ),
aRtlSyms( aGblStrings, SbRTL, this ),
- aGen( *pm, this, 1024 )
+ aGen( *pm, this )
{
eEndTok = NIL;
pProc = nullptr;
diff --git a/basic/source/inc/buffer.hxx b/basic/source/inc/buffer.hxx
index aa9111c54785..233d94fec177 100644
--- a/basic/source/inc/buffer.hxx
+++ b/basic/source/inc/buffer.hxx
@@ -19,32 +19,34 @@
#pragma once
+#include <basic/sberrors.hxx>
+#include <rtl/ustring.hxx>
#include <sal/types.h>
-#include <memory>
+#include <vector>
-class SbiParser;
+// Stores all numbers big endian
class SbiBuffer {
- SbiParser* pParser; // for error messages
- std::unique_ptr<char[]> pBuf;
- char* pCur;
- sal_uInt32 nOff;
- sal_uInt32 nSize;
- short nInc;
- bool Check( sal_Int32 );
+ std::vector<sal_uInt8> m_aBuf;
+ ErrCode m_aErrCode;
+ OUString m_sErrMsg;
+
+ template <typename T> void append(T n);
+
public:
- SbiBuffer( SbiParser*, short ); // increment
- ~SbiBuffer();
+ SbiBuffer() { m_aBuf.reserve(1024); }
void Patch( sal_uInt32, sal_uInt32 );
void Chain( sal_uInt32 );
void operator += (sal_Int8); // save character
void operator += (sal_Int16); // save integer
- bool operator += (sal_uInt8); // save character
- bool operator += (sal_uInt16); // save integer
- bool operator += (sal_uInt32); // save integer
+ void operator += (sal_uInt8); // save character
+ void operator += (sal_uInt16); // save integer
+ void operator += (sal_uInt32); // save integer
void operator += (sal_Int32); // save integer
- char* GetBuffer(); // give out buffer (delete yourself!)
- sal_uInt32 GetSize() const { return nOff; }
+ std::vector<sal_uInt8>&& GetBuffer() { return std::move(m_aBuf); } // pass ownership
+ sal_uInt32 GetSize() const { return m_aBuf.size(); }
+ ErrCode GetErrCode() const { return m_aErrCode; }
+ OUString GetErrMessage() const { return m_sErrMsg; }
};
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/source/inc/codegen.hxx b/basic/source/inc/codegen.hxx
index c5111002f110..da573cd3b627 100644
--- a/basic/source/inc/codegen.hxx
+++ b/basic/source/inc/codegen.hxx
@@ -33,7 +33,7 @@ class SbiCodeGen {
bool bStmnt; // true: statement-opcode is pending
public:
- SbiCodeGen( SbModule&, SbiParser*, short );
+ SbiCodeGen(SbModule&, SbiParser*);
SbiParser* GetParser() { return pParser; }
SbModule& GetModule() { return rMod; }
sal_uInt32 Gen( SbiOpcode );
@@ -60,18 +60,21 @@ template < class T, class S >
class PCodeBuffConvertor
{
T m_nSize;
- sal_uInt8* m_pStart;
- sal_uInt8* m_pCnvtdBuf;
- S m_nCnvtdSize;
+ const sal_uInt8* m_pStart;
+ std::vector<sal_uInt8> m_aCnvtdBuf;
PCodeBuffConvertor(const PCodeBuffConvertor& ) = delete;
PCodeBuffConvertor& operator = ( const PCodeBuffConvertor& ) = delete;
public:
- PCodeBuffConvertor( sal_uInt8* pCode, T nSize ): m_nSize( nSize ), m_pStart( pCode ), m_pCnvtdBuf( nullptr ), m_nCnvtdSize( 0 ){ convert(); }
- S GetSize(){ return m_nCnvtdSize; }
+ PCodeBuffConvertor(const sal_uInt8* pCode, T nSize)
+ : m_nSize(nSize)
+ , m_pStart(pCode)
+ {
+ convert();
+ }
void convert();
- // Caller owns the buffer returned
- sal_uInt8* GetBuffer() { return m_pCnvtdBuf; }
+ // pass ownership
+ std::vector<sal_uInt8>&& GetBuffer() { return std::move(m_aCnvtdBuf); }
};
// #111897 PARAM_INFO flags start at 0x00010000 to not
diff --git a/basic/source/inc/image.hxx b/basic/source/inc/image.hxx
index bf87f725cc8c..f0ea655d6899 100644
--- a/basic/source/inc/image.hxx
+++ b/basic/source/inc/image.hxx
@@ -23,6 +23,7 @@
#include <rtl/ustring.hxx>
#include "filefmt.hxx"
#include <o3tl/typed_flags_set.hxx>
+#include <vector>
// This class reads in the image that's been produced by the compiler
// and manages the access to the single elements.
@@ -47,13 +48,11 @@ class SbiImage {
SbxArrayRef rEnums; // Enum types
std::vector<sal_uInt32> mvStringOffsets; // StringId-Offsets
std::unique_ptr<sal_Unicode[]> pStrings; // StringPool
- std::unique_ptr<char[]> pCode; // Code-Image
- std::unique_ptr<char[]> pLegacyPCode; // Code-Image
+ std::vector<sal_uInt8> aCode; // Code-Image
+ std::vector<sal_uInt8> aLegacyPCode; // Code-Image
bool bError;
SbiImageFlags nFlags;
sal_uInt32 nStringSize;
- sal_uInt32 nCodeSize;
- sal_uInt16 nLegacyCodeSize;
sal_uInt16 nDimBase; // OPTION BASE value
rtl_TextEncoding eCharSet;
// temporary management-variable:
@@ -62,7 +61,7 @@ class SbiImage {
// routines for the compiler:
void MakeStrings( short ); // establish StringPool
void AddString( const OUString& );
- void AddCode( std::unique_ptr<char[]>, sal_uInt32 );
+ void AddCode(std::vector<sal_uInt8>&&);
void AddType(SbxObject const *);
void AddEnum(SbxObject *);
@@ -82,8 +81,8 @@ public:
bool Save( SvStream&, sal_uInt32 = B_CURVERSION );
bool IsError() const { return bError; }
- const char* GetCode() const { return pCode.get(); }
- sal_uInt32 GetCodeSize() const { return nCodeSize; }
+ const sal_uInt8* GetCode() const { return aCode.data(); }
+ sal_uInt32 GetCodeSize() const { return aCode.size(); }
sal_uInt16 GetBase() const { return nDimBase; }
OUString GetString( short nId ) const;
const SbxObject* FindType (const OUString& aTypeName) const;
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 0606b78ca420..78e2a5ac4358 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -609,7 +609,7 @@ SbiRuntime::SbiRuntime( SbModule* pm, SbMethod* pe, sal_uInt32 nStart )
pRestart = nullptr;
pNext = nullptr;
pCode =
- pStmnt = reinterpret_cast<const sal_uInt8*>(pImg->GetCode()) + nStart;
+ pStmnt = pImg->GetCode() + nStart;
bRun =
bError = true;
bInError = false;
@@ -2972,7 +2972,7 @@ void SbiRuntime::StepJUMP( sal_uInt32 nOp1 )
if( nOp1 >= pImg->GetCodeSize() )
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
#endif
- pCode = reinterpret_cast<const sal_uInt8*>(pImg->GetCode()) + nOp1;
+ pCode = pImg->GetCode() + nOp1;
}
// evaluate TOS, conditional jump (+target)
@@ -3014,7 +3014,7 @@ void SbiRuntime::StepONJUMP( sal_uInt32 nOp1 )
}
if( n < 1 || o3tl::make_unsigned(n) > nOp1 )
n = static_cast<sal_Int16>( nOp1 + 1 );
- nOp1 = static_cast<sal_uInt32>( reinterpret_cast<const char*>(pCode) - pImg->GetCode() ) + 5 * --n;
+ nOp1 = static_cast<sal_uInt32>(pCode - pImg->GetCode()) + 5 * --n;
StepJUMP( nOp1 );
}
@@ -3025,7 +3025,7 @@ void SbiRuntime::StepGOSUB( sal_uInt32 nOp1 )
PushGosub( pCode );
if( nOp1 >= pImg->GetCodeSize() )
StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
- pCode = reinterpret_cast<const sal_uInt8*>(pImg->GetCode()) + nOp1;
+ pCode = pImg->GetCode() + nOp1;
}
// UP-return (+0 or target)