1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 03:52:19 +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

@ -240,6 +240,15 @@ 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--;