1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-08 11:38:21 +02:00

OOB protection in GetLineCharAtIdx

This commit is contained in:
Brian Fiete 2022-02-02 07:50:25 -05:00
parent 6c3944170d
commit b8c7a29b84

View file

@ -239,7 +239,16 @@ int BfParserData::GetCharIdAtIndex(int findIndex)
}
void BfParserData::GetLineCharAtIdx(int idx, int& line, int& lineChar)
{
{
if (mJumpTableSize <= 0)
{
line = 0;
lineChar = 0;
return;
}
if (idx >= mSrcLength)
idx = mSrcLength - 1;
auto* jumpEntry = mJumpTable + (idx / PARSER_JUMPTABLE_DIVIDE);
if (jumpEntry->mCharIdx > idx)
jumpEntry--;