mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-02-22 21:40:42 +00:00
Bug #613: fixed assert in string literal access function
This commit is contained in:
parent
7129947674
commit
a1ece7de30
@ -34,17 +34,20 @@ namespace Interpreter
|
|||||||
|
|
||||||
std::string Runtime::getStringLiteral (int index) const
|
std::string Runtime::getStringLiteral (int index) const
|
||||||
{
|
{
|
||||||
assert (index>=0 && index<static_cast<int> (mCode[3]));
|
assert (index>=0 && static_cast<int> (mCode[3])>0);
|
||||||
|
|
||||||
const char *literalBlock =
|
const char *literalBlock =
|
||||||
reinterpret_cast<const char *> (mCode + 4 + mCode[0] + mCode[1] + mCode[2]);
|
reinterpret_cast<const char *> (mCode + 4 + mCode[0] + mCode[1] + mCode[2]);
|
||||||
|
|
||||||
|
int offset = 0;
|
||||||
|
|
||||||
for (; index; --index)
|
for (; index; --index)
|
||||||
{
|
{
|
||||||
literalBlock += std::strlen (literalBlock) + 1;
|
offset += std::strlen (literalBlock+offset) + 1;
|
||||||
|
assert (offset/4<static_cast<int> (mCode[3]));
|
||||||
}
|
}
|
||||||
|
|
||||||
return literalBlock;
|
return literalBlock+offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Runtime::configure (const Interpreter::Type_Code *code, int codeSize, Context& context)
|
void Runtime::configure (const Interpreter::Type_Code *code, int codeSize, Context& context)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user